audit log (I forgot)
This commit is contained in:
parent
5b807a667d
commit
e80af275f7
2 changed files with 13 additions and 4 deletions
|
@ -39,13 +39,16 @@ public class AuditLogService
|
|||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task LogSystem(AuditLogType type, params object[] data)
|
||||
public Task LogSystem(AuditLogType type, Action<AuditLogParameters> data)
|
||||
{
|
||||
var al = new AuditLogParameters();
|
||||
data(al);
|
||||
|
||||
var entry = new AuditLogEntry()
|
||||
{
|
||||
Type = type,
|
||||
System = true,
|
||||
JsonData = data.Length == 0 ? "" : JsonConvert.SerializeObject(data)
|
||||
JsonData = al.Build()
|
||||
};
|
||||
|
||||
Repository.Add(entry);
|
||||
|
|
|
@ -158,7 +158,10 @@ public class UserService
|
|||
|
||||
if (isSystemAction)
|
||||
{
|
||||
await AuditLogService.LogSystem(AuditLogType.ChangePassword, user.Email);
|
||||
await AuditLogService.LogSystem(AuditLogType.ChangePassword, x=>
|
||||
{
|
||||
x.Add<User>(user.Email);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -188,7 +191,10 @@ public class UserService
|
|||
|
||||
if (BCrypt.Net.BCrypt.Verify(password, user.Password))
|
||||
{
|
||||
await AuditLogService.LogSystem(AuditLogType.Login, user.Email);
|
||||
await AuditLogService.LogSystem(AuditLogType.Login, x =>
|
||||
{
|
||||
x.Add<User>(user.Email);
|
||||
});
|
||||
return user;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue