Fix permanent deletion of orphaned organization ciphers

When a cipher's collection is deleted, the cipher becomes orphaned and
cannot be permanently deleted. Changed DeleteAdmin to use GetByIdAsyncAdmin
to bypass collection-based filtering, consistent with other admin endpoints.
This commit is contained in:
Rui Tome
2026-01-15 13:53:50 +00:00
parent 2e0e103076
commit 1d96c43c59

View File

@@ -976,14 +976,14 @@ public class CiphersController : Controller
public async Task DeleteAdmin(Guid id)
{
var userId = _userService.GetProperUserId(User).Value;
var cipher = await GetByIdAsync(id, userId);
var cipher = await GetByIdAsyncAdmin(id);
if (cipher == null || !cipher.OrganizationId.HasValue ||
!await CanDeleteOrRestoreCipherAsAdminAsync(cipher.OrganizationId.Value, new[] { cipher.Id }))
{
throw new NotFoundException();
}
await _cipherService.DeleteAsync(cipher, userId, true);
await _cipherService.DeleteAsync(new CipherDetails(cipher), userId, true);
}
[HttpPost("{id}/delete-admin")]