1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 21:18:13 -05:00

upgrade owner to premium on SH org create

This commit is contained in:
Kyle Spearrin 2017-10-04 16:07:34 -04:00
parent f2ae8bc132
commit e3f12c46c3

View File

@ -554,8 +554,8 @@ namespace Bit.Core.Services
"hosting of organizations and that the installation id matches your current installation.");
}
var plan = StaticStore.Plans.FirstOrDefault(p => p.Type == license.PlanType && !p.Disabled);
if(plan == null)
if(license.PlanType != PlanType.Custom &&
StaticStore.Plans.FirstOrDefault(p => p.Type == license.PlanType && !p.Disabled) == null)
{
throw new BadRequestException("Plan not found.");
}
@ -590,6 +590,15 @@ namespace Bit.Core.Services
Directory.CreateDirectory(dir);
File.WriteAllText($"{dir}/{organization.Id}.json", JsonConvert.SerializeObject(license, Formatting.Indented));
// self-hosted org users get premium access
if(!owner.Premium && result.Item1.Enabled)
{
owner.Premium = true;
owner.MaxStorageGb = 10240; // 10 TB
owner.RevisionDate = DateTime.UtcNow;
await _userRepository.ReplaceAsync(owner);
}
return result;
}