mirror of
https://github.com/bitwarden/server.git
synced 2025-01-04 19:07:50 +01:00
cipher delete for admin
This commit is contained in:
parent
552b117821
commit
a9b0748d07
@ -207,5 +207,20 @@ namespace Bit.Api.Controllers
|
|||||||
|
|
||||||
await _cipherService.DeleteAsync(cipher, userId);
|
await _cipherService.DeleteAsync(cipher, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpDelete("{id}/admin")]
|
||||||
|
[HttpPost("{id}/delete-admin")]
|
||||||
|
public async Task DeleteAdmin(string id)
|
||||||
|
{
|
||||||
|
var userId = _userService.GetProperUserId(User).Value;
|
||||||
|
var cipher = await _cipherRepository.GetByIdAsync(new Guid(id));
|
||||||
|
if(cipher == null || !cipher.OrganizationId.HasValue ||
|
||||||
|
!_currentContext.OrganizationAdmin(cipher.OrganizationId.Value))
|
||||||
|
{
|
||||||
|
throw new NotFoundException();
|
||||||
|
}
|
||||||
|
|
||||||
|
await _cipherService.DeleteAsync(cipher, userId, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace Bit.Core.Services
|
|||||||
public interface ICipherService
|
public interface ICipherService
|
||||||
{
|
{
|
||||||
Task SaveAsync(CipherDetails cipher, Guid savingUserId);
|
Task SaveAsync(CipherDetails cipher, Guid savingUserId);
|
||||||
Task DeleteAsync(CipherDetails cipher, Guid deletingUserId);
|
Task DeleteAsync(Cipher cipher, Guid deletingUserId, bool orgAdmin = false);
|
||||||
Task SaveFolderAsync(Folder folder);
|
Task SaveFolderAsync(Folder folder);
|
||||||
Task DeleteFolderAsync(Folder folder);
|
Task DeleteFolderAsync(Folder folder);
|
||||||
Task ShareAsync(Cipher cipher, Guid organizationId, IEnumerable<Guid> subvaultIds, Guid userId);
|
Task ShareAsync(Cipher cipher, Guid organizationId, IEnumerable<Guid> subvaultIds, Guid userId);
|
||||||
|
@ -65,9 +65,9 @@ namespace Bit.Core.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteAsync(CipherDetails cipher, Guid deletingUserId)
|
public async Task DeleteAsync(Cipher cipher, Guid deletingUserId, bool orgAdmin = false)
|
||||||
{
|
{
|
||||||
if(!(await UserCanEditAsync(cipher, deletingUserId)))
|
if(!orgAdmin && !(await UserCanEditAsync(cipher, deletingUserId)))
|
||||||
{
|
{
|
||||||
throw new BadRequestException("Not an admin.");
|
throw new BadRequestException("Not an admin.");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user