Example #1
0
        public async Task PostImport([FromQuery] string organizationId, [FromBody] ImportOrganizationCiphersRequestModel model)
        {
            var orgId = new Guid(organizationId);

            if (!_currentContext.OrganizationAdmin(orgId))
            {
                throw new NotFoundException();
            }

            var userId      = _userService.GetProperUserId(User).Value;
            var collections = model.Collections.Select(c => c.ToCollection(orgId)).ToList();
            var ciphers     = model.Logins.Select(l => l.ToOrganizationCipherDetails(orgId)).ToList();
            await _cipherService.ImportCiphersAsync(collections, ciphers, model.CollectionRelationships, userId);
        }
Example #2
0
        public async Task PostImport([FromQuery] string organizationId, [FromBody] ImportOrganizationCiphersRequestModel model)
        {
            if (!_globalSettings.SelfHosted &&
                (model.Ciphers.Count() > 5000 || model.CollectionRelationships.Count() > 5000 ||
                 model.Collections.Count() > 200))
            {
                throw new BadRequestException("You cannot import this much data at once.");
            }

            var orgId = new Guid(organizationId);

            if (!_currentContext.OrganizationAdmin(orgId))
            {
                throw new NotFoundException();
            }

            var userId      = _userService.GetProperUserId(User).Value;
            var collections = model.Collections.Select(c => c.ToCollection(orgId)).ToList();
            var ciphers     = model.Ciphers.Select(l => l.ToOrganizationCipherDetails(orgId)).ToList();
            await _cipherService.ImportCiphersAsync(collections, ciphers, model.CollectionRelationships, userId);
        }