mirror of
https://github.com/azaion/admin.git
synced 2026-04-22 08:56:33 +00:00
Add LastLogin and CreatedAt to User
This commit is contained in:
@@ -34,7 +34,8 @@ public class UserService(IDbFactory dbFactory, ICache cache) : IUserService
|
||||
Id = Guid.NewGuid(),
|
||||
Email = request.Email,
|
||||
PasswordHash = request.Password.ToHash(),
|
||||
Role = request.Role
|
||||
Role = request.Role,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
}, token: ct);
|
||||
});
|
||||
}
|
||||
@@ -108,12 +109,23 @@ public class UserService(IDbFactory dbFactory, ICache cache) : IUserService
|
||||
{
|
||||
await UpdateHardware(user.Email, hardware, ct);
|
||||
cache.Invalidate(User.GetCacheKey(user.Email));
|
||||
await UpdateLastLoginDate(user, ct);
|
||||
return requestHWHash;
|
||||
}
|
||||
|
||||
var userHWHash = Security.GetHWHash(user.Hardware);
|
||||
if (userHWHash != requestHWHash)
|
||||
throw new BusinessException(ExceptionEnum.HardwareIdMismatch);
|
||||
await UpdateLastLoginDate(user, ct);
|
||||
return userHWHash;
|
||||
}
|
||||
|
||||
private async Task UpdateLastLoginDate(User user, CancellationToken ct = default)
|
||||
{
|
||||
await dbFactory.Run(async db =>
|
||||
await db.Users.UpdateAsync(x => x.Email == user.Email, u => new User
|
||||
{
|
||||
LastLogin = DateTime.UtcNow
|
||||
}, ct));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user