feat(api): добавлено поле lastLogon в таблицы Users, Hosts
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
public string? WorkGroup { get; set; }
|
||||
|
||||
public string? ResponseArea { get; set; }
|
||||
|
||||
public DateTimeOffset? LastLogon { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public DateTimeOffset? LastLogon { get; set; }
|
||||
|
||||
public List<RoleResponse>? Roles { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,16 +44,28 @@ namespace PARR.API.Services.Implementations
|
||||
|
||||
var user = await userService.GetByIpWithRolesAsync(ipAddress);
|
||||
if (user != null)
|
||||
{
|
||||
user.Roles.ToList().ForEach(t =>
|
||||
{
|
||||
if (t.Role != null)
|
||||
roles.Add(new UserRoleInCache { Name = t.Role.Name, Description = t.Role.Description });
|
||||
});
|
||||
|
||||
// сохраняем время входа
|
||||
user.LastLogon = DateTimeOffset.UtcNow;
|
||||
await userService.CommitAsync();
|
||||
}
|
||||
|
||||
var host = await hostService.GetByIpAsync(ipAddress);
|
||||
if (host != null)
|
||||
{
|
||||
roles.Add(new UserRoleInCache { Name = ParrRoles.Agent.Role, Description = ParrRoles.Agent.Description });
|
||||
|
||||
// сохраняем время входа
|
||||
host.LastLogon = DateTimeOffset.UtcNow;
|
||||
await hostService.CommitAsync();
|
||||
}
|
||||
|
||||
if (user == null && host == null)
|
||||
{
|
||||
// если это не пользователь и не хост, добавляем в кэш на блокировку
|
||||
|
||||
Reference in New Issue
Block a user