1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 16:42:50 -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

View File

@ -38,24 +38,14 @@ namespace Bit.Core.Services
throw new BadRequestException("This organization cannot use policies.");
}
var now = DateTime.UtcNow;
if(policy.Id == default(Guid))
{
policy.CreationDate = policy.RevisionDate = DateTime.UtcNow;
await _policyRepository.CreateAsync(policy);
await _eventService.LogPolicyEventAsync(policy, Enums.EventType.Policy_Created);
policy.CreationDate = now;
}
else
{
policy.RevisionDate = DateTime.UtcNow;
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);
policy.RevisionDate = DateTime.UtcNow;
await _policyRepository.UpsertAsync(policy);
await _eventService.LogPolicyEventAsync(policy, Enums.EventType.Policy_Updated);
}
}
}