fix: populate LastLogin/BannedAt/UpdatedAt in UserInfoDto mapping

UsersMapper.ToGetUsersDto() was not copying LastLogin, BannedAt, or
UpdatedAt from the User entity to the UserInfoDto, causing the client
to always receive null for these fields. Added the missing mappings.

Also added null fallback ('Never') for LastLogin display on the User
page to prevent NullReferenceException when the value has not been set.
This commit is contained in:
2026-07-08 02:32:12 +02:00
parent bf3e5e619b
commit 2159eaec08
2 changed files with 10 additions and 7 deletions

View File

@@ -14,12 +14,15 @@ public static class UsersMapper {
/// <returns>A UserInfoDto object containing the mapped data.</returns>
public static UserInfoDto ToGetUsersDto(this User user) {
return new UserInfoDto {
Id = user.Id,
Email = user.Email,
Username = user.Username,
CreatedAt = user.CreatedAt,
IsBanned = user.BannedAt != null,
DeletedAt = user.DeletedAt,
Id = user.Id,
Email = user.Email,
Username = user.Username,
CreatedAt = user.CreatedAt,
IsBanned = user.BannedAt != null,
BannedAt = user.BannedAt,
LastLogin = user.LastLogin,
UpdatedAt = user.UpdatedAt,
DeletedAt = user.DeletedAt,
AccessLevel = user.AccessLevel,
};
}

View File

@@ -24,7 +24,7 @@
</div>
<div class="row">
<div class="col-2"><i class="bi bi-door-open"></i> Last Login:</div>
<div class="col-2">@user?.LastLogin?.ToString("D")</div>
<div class="col-2">@(user?.LastLogin?.ToString("D") ?? "Never")</div>
</div>
<div class="row">
<div class="col-2"><i class="bi bi-ban"></i>Banned:</div>