|
|
|
@ -911,7 +911,7 @@ public class CiphersController : Controller |
|
|
|
|
|
|
|
|
|
|
|
[HttpPut("{id}/archive")] |
|
|
|
[HttpPut("{id}/archive")] |
|
|
|
[RequireFeature(FeatureFlagKeys.ArchiveVaultItems)] |
|
|
|
[RequireFeature(FeatureFlagKeys.ArchiveVaultItems)] |
|
|
|
public async Task<CipherMiniResponseModel> PutArchive(Guid id) |
|
|
|
public async Task<CipherResponseModel> PutArchive(Guid id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var userId = _userService.GetProperUserId(User).Value; |
|
|
|
var userId = _userService.GetProperUserId(User).Value; |
|
|
|
|
|
|
|
|
|
|
|
@ -922,12 +922,16 @@ public class CiphersController : Controller |
|
|
|
throw new BadRequestException("Cipher was not archived. Ensure the provided ID is correct and you have permission to archive it."); |
|
|
|
throw new BadRequestException("Cipher was not archived. Ensure the provided ID is correct and you have permission to archive it."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return new CipherMiniResponseModel(archivedCipherOrganizationDetails.First(), _globalSettings, archivedCipherOrganizationDetails.First().OrganizationUseTotp); |
|
|
|
return new CipherResponseModel(archivedCipherOrganizationDetails.First(), |
|
|
|
|
|
|
|
await _userService.GetUserByIdAsync(userId), |
|
|
|
|
|
|
|
await _applicationCacheService.GetOrganizationAbilitiesAsync(), |
|
|
|
|
|
|
|
_globalSettings |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpPut("archive")] |
|
|
|
[HttpPut("archive")] |
|
|
|
[RequireFeature(FeatureFlagKeys.ArchiveVaultItems)] |
|
|
|
[RequireFeature(FeatureFlagKeys.ArchiveVaultItems)] |
|
|
|
public async Task<ListResponseModel<CipherMiniResponseModel>> PutArchiveMany([FromBody] CipherBulkArchiveRequestModel model) |
|
|
|
public async Task<ListResponseModel<CipherResponseModel>> PutArchiveMany([FromBody] CipherBulkArchiveRequestModel model) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500) |
|
|
|
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -935,6 +939,7 @@ public class CiphersController : Controller |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var userId = _userService.GetProperUserId(User).Value; |
|
|
|
var userId = _userService.GetProperUserId(User).Value; |
|
|
|
|
|
|
|
var user = await _userService.GetUserByIdAsync(userId); |
|
|
|
|
|
|
|
|
|
|
|
var cipherIdsToArchive = new HashSet<Guid>(model.Ids); |
|
|
|
var cipherIdsToArchive = new HashSet<Guid>(model.Ids); |
|
|
|
|
|
|
|
|
|
|
|
@ -945,9 +950,14 @@ public class CiphersController : Controller |
|
|
|
throw new BadRequestException("No ciphers were archived. Ensure the provided IDs are correct and you have permission to archive them."); |
|
|
|
throw new BadRequestException("No ciphers were archived. Ensure the provided IDs are correct and you have permission to archive them."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var responses = archivedCiphers.Select(c => new CipherMiniResponseModel(c, _globalSettings, c.OrganizationUseTotp)); |
|
|
|
var organizationAbilities = await _applicationCacheService.GetOrganizationAbilitiesAsync(); |
|
|
|
|
|
|
|
var responses = archivedCiphers.Select(c => new CipherResponseModel(c, |
|
|
|
|
|
|
|
user, |
|
|
|
|
|
|
|
organizationAbilities, |
|
|
|
|
|
|
|
_globalSettings |
|
|
|
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
|
|
return new ListResponseModel<CipherMiniResponseModel>(responses); |
|
|
|
return new ListResponseModel<CipherResponseModel>(responses); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpDelete("{id}")] |
|
|
|
[HttpDelete("{id}")] |
|
|
|
@ -1109,7 +1119,7 @@ public class CiphersController : Controller |
|
|
|
|
|
|
|
|
|
|
|
[HttpPut("{id}/unarchive")] |
|
|
|
[HttpPut("{id}/unarchive")] |
|
|
|
[RequireFeature(FeatureFlagKeys.ArchiveVaultItems)] |
|
|
|
[RequireFeature(FeatureFlagKeys.ArchiveVaultItems)] |
|
|
|
public async Task<CipherMiniResponseModel> PutUnarchive(Guid id) |
|
|
|
public async Task<CipherResponseModel> PutUnarchive(Guid id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var userId = _userService.GetProperUserId(User).Value; |
|
|
|
var userId = _userService.GetProperUserId(User).Value; |
|
|
|
|
|
|
|
|
|
|
|
@ -1120,12 +1130,16 @@ public class CiphersController : Controller |
|
|
|
throw new BadRequestException("Cipher was not unarchived. Ensure the provided ID is correct and you have permission to archive it."); |
|
|
|
throw new BadRequestException("Cipher was not unarchived. Ensure the provided ID is correct and you have permission to archive it."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return new CipherMiniResponseModel(unarchivedCipherDetails.First(), _globalSettings, unarchivedCipherDetails.First().OrganizationUseTotp); |
|
|
|
return new CipherResponseModel(unarchivedCipherDetails.First(), |
|
|
|
|
|
|
|
await _userService.GetUserByIdAsync(userId), |
|
|
|
|
|
|
|
await _applicationCacheService.GetOrganizationAbilitiesAsync(), |
|
|
|
|
|
|
|
_globalSettings |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpPut("unarchive")] |
|
|
|
[HttpPut("unarchive")] |
|
|
|
[RequireFeature(FeatureFlagKeys.ArchiveVaultItems)] |
|
|
|
[RequireFeature(FeatureFlagKeys.ArchiveVaultItems)] |
|
|
|
public async Task<ListResponseModel<CipherMiniResponseModel>> PutUnarchiveMany([FromBody] CipherBulkUnarchiveRequestModel model) |
|
|
|
public async Task<ListResponseModel<CipherResponseModel>> PutUnarchiveMany([FromBody] CipherBulkUnarchiveRequestModel model) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500) |
|
|
|
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -1133,6 +1147,8 @@ public class CiphersController : Controller |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var userId = _userService.GetProperUserId(User).Value; |
|
|
|
var userId = _userService.GetProperUserId(User).Value; |
|
|
|
|
|
|
|
var user = await _userService.GetUserByIdAsync(userId); |
|
|
|
|
|
|
|
var organizationAbilities = await _applicationCacheService.GetOrganizationAbilitiesAsync(); |
|
|
|
|
|
|
|
|
|
|
|
var cipherIdsToUnarchive = new HashSet<Guid>(model.Ids); |
|
|
|
var cipherIdsToUnarchive = new HashSet<Guid>(model.Ids); |
|
|
|
|
|
|
|
|
|
|
|
@ -1143,9 +1159,9 @@ public class CiphersController : Controller |
|
|
|
throw new BadRequestException("Ciphers were not unarchived. Ensure the provided ID is correct and you have permission to archive it."); |
|
|
|
throw new BadRequestException("Ciphers were not unarchived. Ensure the provided ID is correct and you have permission to archive it."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var responses = unarchivedCipherOrganizationDetails.Select(c => new CipherMiniResponseModel(c, _globalSettings, c.OrganizationUseTotp)); |
|
|
|
var responses = unarchivedCipherOrganizationDetails.Select(c => new CipherResponseModel(c, user, organizationAbilities, _globalSettings)); |
|
|
|
|
|
|
|
|
|
|
|
return new ListResponseModel<CipherMiniResponseModel>(responses); |
|
|
|
return new ListResponseModel<CipherResponseModel>(responses); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpPut("{id}/restore")] |
|
|
|
[HttpPut("{id}/restore")] |
|
|
|
|