示例#1
0
        public async Task PutShare(string id, [FromBody] CipherShareRequestModel model)
        {
            var userId = _userService.GetProperUserId(User).Value;
            var cipher = await _cipherRepository.GetByIdAsync(new Guid(id), userId);

            if (cipher == null || cipher.UserId != userId ||
                !_currentContext.OrganizationUser(new Guid(model.Cipher.OrganizationId)))
            {
                throw new NotFoundException();
            }

            await _cipherService.ShareAsync(model.Cipher.ToCipher(cipher), new Guid(model.Cipher.OrganizationId),
                                            model.CollectionIds.Select(c => new Guid(c)), userId);
        }
示例#2
0
        public async Task <CipherResponseModel> PutShare(string id, [FromBody] CipherShareRequestModel model)
        {
            var userId   = _userService.GetProperUserId(User).Value;
            var cipherId = new Guid(id);
            var cipher   = await _cipherRepository.GetByIdAsync(cipherId);

            if (cipher == null || cipher.UserId != userId ||
                !_currentContext.OrganizationUser(new Guid(model.Cipher.OrganizationId)))
            {
                throw new NotFoundException();
            }

            var original = CoreHelpers.CloneObject(cipher);
            await _cipherService.ShareAsync(original, model.Cipher.ToCipher(cipher),
                                            new Guid(model.Cipher.OrganizationId), model.CollectionIds.Select(c => new Guid(c)), userId);

            var sharedCipher = await _cipherRepository.GetByIdAsync(cipherId, userId);

            var response = new CipherResponseModel(sharedCipher, _globalSettings);

            return(response);
        }