public async Task <SyncResponseModel> Get() { var user = await _userService.GetUserByPrincipalAsync(User); if (user == null) { throw new BadRequestException("User not found."); } var organizationUserDetails = await _organizationUserRepository.GetManyDetailsByUserAsync(user.Id, OrganizationUserStatusType.Confirmed); var hasEnabledOrgs = organizationUserDetails.Any(o => o.Enabled); var folders = await _folderRepository.GetManyByUserIdAsync(user.Id); var ciphers = await _cipherRepository.GetManyByUserIdAsync(user.Id, hasEnabledOrgs); IEnumerable <Collection> collections = null; IDictionary <Guid, IGrouping <Guid, CollectionCipher> > collectionCiphersGroupDict = null; if (hasEnabledOrgs) { collections = await _collectionRepository.GetManyByUserIdAsync(user.Id, false); var collectionCiphers = await _collectionCipherRepository.GetManyByUserIdAsync(user.Id); collectionCiphersGroupDict = collectionCiphers.GroupBy(c => c.CipherId).ToDictionary(s => s.Key); } var response = new SyncResponseModel(_globalSettings, user, organizationUserDetails, folders, collections, ciphers, collectionCiphersGroupDict); return(response); }
public async Task <SyncResponseModel> Get([FromQuery] bool excludeDomains = false) { var user = await _userService.GetUserByPrincipalAsync(User); if (user == null) { throw new BadRequestException("User not found."); } var organizationUserDetails = await _organizationUserRepository.GetManyDetailsByUserAsync(user.Id, OrganizationUserStatusType.Confirmed); var providerUserDetails = await _providerUserRepository.GetManyDetailsByUserAsync(user.Id, ProviderUserStatusType.Confirmed); var providerUserOrganizationDetails = await _providerUserRepository.GetManyOrganizationDetailsByUserAsync(user.Id, ProviderUserStatusType.Confirmed); var hasEnabledOrgs = organizationUserDetails.Any(o => o.Enabled); var folders = await _folderRepository.GetManyByUserIdAsync(user.Id); var ciphers = await _cipherRepository.GetManyByUserIdAsync(user.Id, hasEnabledOrgs); var sends = await _sendRepository.GetManyByUserIdAsync(user.Id); IEnumerable <CollectionDetails> collections = null; IDictionary <Guid, IGrouping <Guid, CollectionCipher> > collectionCiphersGroupDict = null; IEnumerable <Policy> policies = null; if (hasEnabledOrgs) { collections = await _collectionRepository.GetManyByUserIdAsync(user.Id); var collectionCiphers = await _collectionCipherRepository.GetManyByUserIdAsync(user.Id); collectionCiphersGroupDict = collectionCiphers.GroupBy(c => c.CipherId).ToDictionary(s => s.Key); policies = await _policyRepository.GetManyByUserIdAsync(user.Id); } var userTwoFactorEnabled = await _userService.TwoFactorIsEnabledAsync(user); var userHasPremiumFromOrganization = await _userService.HasPremiumFromOrganization(user); var response = new SyncResponseModel(_globalSettings, user, userTwoFactorEnabled, userHasPremiumFromOrganization, organizationUserDetails, providerUserDetails, providerUserOrganizationDetails, folders, collections, ciphers, collectionCiphersGroupDict, excludeDomains, policies, sends); return(response); }
public async Task <SyncResponseModel> Get() { var user = await _userService.GetUserByPrincipalAsync(User); var organizationUserDetails = await _organizationUserRepository.GetManyDetailsByUserAsync(user.Id, OrganizationUserStatusType.Confirmed); var folders = await _folderRepository.GetManyByUserIdAsync(user.Id); var ciphers = await _cipherRepository.GetManyByUserIdAsync(user.Id); var response = new SyncResponseModel(_globalSettings, user, organizationUserDetails, folders, ciphers); return(response); }