1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-23 17:07:42 +01:00

premium check for attachments

This commit is contained in:
Kyle Spearrin 2017-07-05 16:06:53 -04:00
parent 87a216e523
commit 2afef85f85

View File

@ -109,11 +109,21 @@ namespace Bit.Core.Services
if(cipher.UserId.HasValue)
{
var user = await _userRepository.GetByIdAsync(cipher.UserId.Value);
if(!user.Premium)
{
throw new BadRequestException("You must be a premium user to use attachments.");
}
storageBytesRemaining = user.StorageBytesRemaining();
}
else if(cipher.OrganizationId.HasValue)
{
var org = await _organizationRepository.GetByIdAsync(cipher.OrganizationId.Value);
if(!org.MaxStorageGb.HasValue)
{
throw new BadRequestException("This organization cannot use attachments.");
}
storageBytesRemaining = org.StorageBytesRemaining();
}