public async Task <CipherResponseModel> Put(Guid id, [FromBody] CipherRequestModel model) { var userId = _userService.GetProperUserId(User).Value; var cipher = await _cipherRepository.GetByIdAsync(id, userId); if (cipher == null) { throw new NotFoundException(); } var collectionIds = (await _collectionCipherRepository.GetManyByUserIdCipherIdAsync(userId, id)).Select(c => c.CollectionId).ToList(); var modelOrgId = string.IsNullOrWhiteSpace(model.OrganizationId) ? (Guid?)null : new Guid(model.OrganizationId); if (cipher.OrganizationId != modelOrgId) { throw new BadRequestException("Organization mismatch. Re-sync if you recently moved this item, " + "then try again."); } await _cipherService.SaveDetailsAsync(model.ToCipherDetails(cipher), userId, model.LastKnownRevisionDate, collectionIds); var response = new CipherResponseModel(cipher, _globalSettings); return(response); }
public async Task <CipherResponseModel> Put(string id, [FromBody] CipherRequestModel model) { var userId = _userService.GetProperUserId(User).Value; var cipher = await _cipherRepository.GetByIdAsync(new Guid(id), userId); if (cipher == null) { throw new NotFoundException(); } var modelOrgId = string.IsNullOrWhiteSpace(model.OrganizationId) ? (Guid?)null : new Guid(model.OrganizationId); if (cipher.OrganizationId != modelOrgId) { throw new BadRequestException("Organization mismatch. Re-sync if you recently shared this item, " + "then try again."); } await _cipherService.SaveDetailsAsync(model.ToCipherDetails(cipher), userId); var response = new CipherResponseModel(cipher, _globalSettings); return(response); }
public CipherData(CipherRequestModel cipher) { Name = cipher.Name; Notes = cipher.Notes; Fields = cipher.Fields?.Select(f => new CipherFieldData(f)); PasswordHistory = cipher.PasswordHistory?.Select(ph => new CipherPasswordHistoryData(ph)); }
public CipherLoginData(CipherRequestModel cipher) : base(cipher) { Uris = cipher.Login.Uris?.Where(u => u != null).Select(u => new CipherLoginUriData(u)); Username = cipher.Login.Username; Password = cipher.Login.Password; Totp = cipher.Login.Totp; }
public async Task <CipherResponseModel> Post([FromBody] CipherRequestModel model) { var userId = _userService.GetProperUserId(User).Value; var cipher = model.ToCipherDetails(userId); await _cipherService.SaveDetailsAsync(cipher, userId); var response = new CipherResponseModel(cipher, _globalSettings); return(response); }
public CipherCardData(CipherRequestModel cipher) : base(cipher) { CardholderName = cipher.Card.CardholderName; Brand = cipher.Card.Brand; Number = cipher.Card.Number; ExpMonth = cipher.Card.ExpMonth; ExpYear = cipher.Card.ExpYear; Code = cipher.Card.Code; }
public CipherLoginData(CipherRequestModel cipher) : base(cipher) { Uris = cipher.Login.Uris?.Where(u => u != null).Select(u => new CipherLoginUriData(u)); Username = cipher.Login.Username; Password = cipher.Login.Password; PasswordRevisionDate = cipher.Login.PasswordRevisionDate; Totp = cipher.Login.Totp; AutofillOnPageLoad = cipher.Login.AutofillOnPageLoad; }
public async Task <CipherMiniResponseModel> PostAdmin([FromBody] CipherRequestModel model) { var cipher = model.ToOrganizationCipher(); if (!_currentContext.OrganizationAdmin(cipher.OrganizationId.Value)) { throw new NotFoundException(); } var userId = _userService.GetProperUserId(User).Value; await _cipherService.SaveAsync(cipher, userId, true); var response = new CipherMiniResponseModel(cipher, _globalSettings, false); return(response); }
public async Task <CipherResponseModel> Post([FromBody] CipherRequestModel model) { var userId = _userService.GetProperUserId(User).Value; var cipher = model.ToCipherDetails(userId); if (cipher.OrganizationId.HasValue && !_currentContext.OrganizationUser(cipher.OrganizationId.Value)) { throw new NotFoundException(); } await _cipherService.SaveDetailsAsync(cipher, userId, null, cipher.OrganizationId.HasValue); var response = new CipherResponseModel(cipher, _globalSettings); return(response); }
public async Task <CipherMiniResponseModel> PutAdmin(string id, [FromBody] CipherRequestModel model) { var userId = _userService.GetProperUserId(User).Value; var cipher = await _cipherRepository.GetDetailsByIdAsync(new Guid(id)); if (cipher == null || !cipher.OrganizationId.HasValue || !_currentContext.OrganizationAdmin(cipher.OrganizationId.Value)) { throw new NotFoundException(); } // object cannot be a descendant of CipherDetails, so let's clone it. var cipherClone = CoreHelpers.CloneObject(model.ToCipher(cipher)); await _cipherService.SaveAsync(cipherClone, userId, true); var response = new CipherMiniResponseModel(cipherClone, _globalSettings, cipher.OrganizationUseTotp); return(response); }
public async Task <CipherMiniResponseModel> PutAdmin(Guid id, [FromBody] CipherRequestModel model) { var userId = _userService.GetProperUserId(User).Value; var cipher = await _cipherRepository.GetOrganizationDetailsByIdAsync(id); if (cipher == null || !cipher.OrganizationId.HasValue || !await _currentContext.EditAnyCollection(cipher.OrganizationId.Value)) { throw new NotFoundException(); } var collectionIds = (await _collectionCipherRepository.GetManyByUserIdCipherIdAsync(userId, id)).Select(c => c.CollectionId).ToList(); // object cannot be a descendant of CipherDetails, so let's clone it. var cipherClone = model.ToCipher(cipher).Clone(); await _cipherService.SaveAsync(cipherClone, userId, model.LastKnownRevisionDate, collectionIds, true, false); var response = new CipherMiniResponseModel(cipherClone, _globalSettings, cipher.OrganizationUseTotp); return(response); }
public CipherIdentityData(CipherRequestModel cipher) : base(cipher) { Title = cipher.Identity.Title; FirstName = cipher.Identity.FirstName; MiddleName = cipher.Identity.MiddleName; LastName = cipher.Identity.LastName; Address1 = cipher.Identity.Address1; Address2 = cipher.Identity.Address2; Address3 = cipher.Identity.Address3; City = cipher.Identity.City; State = cipher.Identity.State; PostalCode = cipher.Identity.PostalCode; Country = cipher.Identity.Country; Company = cipher.Identity.Company; Email = cipher.Identity.Email; Phone = cipher.Identity.Phone; SSN = cipher.Identity.SSN; Username = cipher.Identity.Username; PassportNumber = cipher.Identity.PassportNumber; LicenseNumber = cipher.Identity.LicenseNumber; }
public CipherSecureNoteData(CipherRequestModel cipher) : base(cipher) { Type = cipher.SecureNote.Type; }
public CipherData(CipherRequestModel cipher) { Name = cipher.Name; Notes = cipher.Notes; Fields = cipher.Fields?.Select(f => new CipherFieldData(f)); }