From 2afef85f8534d4f0fdca606a71d9b38839fc8ba5 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 5 Jul 2017 16:06:53 -0400 Subject: [PATCH] premium check for attachments --- src/Core/Services/Implementations/CipherService.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Core/Services/Implementations/CipherService.cs b/src/Core/Services/Implementations/CipherService.cs index 284ad0a532..a5f414af01 100644 --- a/src/Core/Services/Implementations/CipherService.cs +++ b/src/Core/Services/Implementations/CipherService.cs @@ -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(); }