1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-13 00:58:13 -05:00

only 1 policy event

This commit is contained in:
Kyle Spearrin 2020-01-20 09:02:41 -05:00
parent f3f1ac57d2
commit 9266546d60
3 changed files with 6 additions and 19 deletions
src/Core

@ -45,8 +45,6 @@
Organization_PurgedVault = 1601, Organization_PurgedVault = 1601,
// Organization_ClientExportedVault = 1602, // Organization_ClientExportedVault = 1602,
Policy_Created = 1700, Policy_Updated = 1700,
Policy_Updated = 1701,
Policy_Deleted = 1702,
} }
} }

@ -6,6 +6,5 @@ namespace Bit.Core.Services
public interface IPolicyService public interface IPolicyService
{ {
Task SaveAsync(Policy policy); Task SaveAsync(Policy policy);
Task DeleteAsync(Policy policy);
} }
} }

@ -38,24 +38,14 @@ namespace Bit.Core.Services
throw new BadRequestException("This organization cannot use policies."); throw new BadRequestException("This organization cannot use policies.");
} }
var now = DateTime.UtcNow;
if(policy.Id == default(Guid)) if(policy.Id == default(Guid))
{ {
policy.CreationDate = policy.RevisionDate = DateTime.UtcNow; policy.CreationDate = now;
await _policyRepository.CreateAsync(policy);
await _eventService.LogPolicyEventAsync(policy, Enums.EventType.Policy_Created);
} }
else policy.RevisionDate = DateTime.UtcNow;
{ await _policyRepository.UpsertAsync(policy);
policy.RevisionDate = DateTime.UtcNow; await _eventService.LogPolicyEventAsync(policy, Enums.EventType.Policy_Updated);
await _policyRepository.ReplaceAsync(policy);
await _eventService.LogPolicyEventAsync(policy, Enums.EventType.Policy_Updated);
}
}
public async Task DeleteAsync(Policy policy)
{
await _policyRepository.DeleteAsync(policy);
await _eventService.LogPolicyEventAsync(policy, Enums.EventType.Policy_Deleted);
} }
} }
} }