1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 16:12:49 -05:00

admin login apis

This commit is contained in:
Kyle Spearrin
2017-04-27 14:50:22 -04:00
parent 44883091f6
commit 8458022a58
5 changed files with 117 additions and 9 deletions

View File

@ -40,7 +40,31 @@ namespace Bit.Core.Services
_pushService = pushService;
}
public async Task SaveAsync(CipherDetails cipher, Guid savingUserId)
public async Task SaveAsync(Cipher cipher, Guid savingUserId, bool orgAdmin = false)
{
if(!orgAdmin && !(await UserCanEditAsync(cipher, savingUserId)))
{
throw new BadRequestException("You do not have permissions to edit this.");
}
if(cipher.Id == default(Guid))
{
await _cipherRepository.CreateAsync(cipher);
// push
await _pushService.PushSyncCipherCreateAsync(cipher);
}
else
{
cipher.RevisionDate = DateTime.UtcNow;
await _cipherRepository.ReplaceAsync(cipher);
// push
await _pushService.PushSyncCipherUpdateAsync(cipher);
}
}
public async Task SaveDetailsAsync(CipherDetails cipher, Guid savingUserId)
{
if(!(await UserCanEditAsync(cipher, savingUserId)))
{