mirror of
https://github.com/bitwarden/server.git
synced 2024-11-22 12:15:36 +01:00
license adjustments for premium creation
This commit is contained in:
parent
9c254a7325
commit
67edcd035c
@ -396,22 +396,36 @@ namespace Bit.Api.Controllers
|
||||
UserLicense license = null;
|
||||
if(valid && _globalSettings.SelfHosted && model.License != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var stream = model.License.OpenReadStream())
|
||||
using(var reader = new StreamReader(stream))
|
||||
{
|
||||
var s = await reader.ReadToEndAsync();
|
||||
license = JsonConvert.DeserializeObject<UserLicense>(s);
|
||||
}
|
||||
}
|
||||
catch
|
||||
if(!HttpContext.Request.ContentLength.HasValue || HttpContext.Request.ContentLength.Value > 51200) // 50 KB
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
using(var stream = model.License.OpenReadStream())
|
||||
using(var reader = new StreamReader(stream))
|
||||
{
|
||||
var s = await reader.ReadToEndAsync();
|
||||
if(string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
license = JsonConvert.DeserializeObject<UserLicense>(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!valid)
|
||||
if(!valid || (_globalSettings.SelfHosted && license == null))
|
||||
{
|
||||
throw new BadRequestException("Invalid license.");
|
||||
}
|
||||
|
@ -572,7 +572,7 @@ namespace Bit.Core.Services
|
||||
|
||||
if(_globalSettings.SelfHosted)
|
||||
{
|
||||
user.MaxStorageGb = 10240;
|
||||
user.MaxStorageGb = 10240; // 10 TB
|
||||
user.LicenseKey = license.LicenseKey;
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user