audit log (I forgot)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user