diff --git a/WatchIt.Common/WatchIt.Common.Model/Accounts/AccountResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Accounts/AccountResponse.cs index a87d407..fb3bc77 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Accounts/AccountResponse.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Accounts/AccountResponse.cs @@ -14,6 +14,15 @@ public class AccountResponse : Account [JsonPropertyName("gender")] public GenderResponse? Gender { get; set; } + [JsonPropertyName("last_active")] + public DateTime LastActive { get; set; } + + [JsonPropertyName("creation_date")] + public DateTime CreationDate { get; set; } + + [JsonPropertyName("is_admin")] + public bool IsAdmin { get; set; } + #endregion @@ -31,6 +40,9 @@ public class AccountResponse : Account Email = account.Email; Description = account.Description; Gender = account.Gender is not null ? new GenderResponse(account.Gender) : null; + LastActive = account.LastActive; + CreationDate = account.CreationDate; + IsAdmin = account.IsAdmin; } #endregion diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Accounts/AccountsControllerService.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Accounts/AccountsControllerService.cs index df37957..af69597 100644 --- a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Accounts/AccountsControllerService.cs +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Accounts/AccountsControllerService.cs @@ -62,6 +62,9 @@ public class AccountsControllerService( RefreshToken = await refreshTokenTask, }; + account.LastActive = DateTime.UtcNow; + await database.SaveChangesAsync(); + logger.LogInformation($"Account with ID {account.Id} was authenticated"); return RequestResult.Ok(response); } @@ -91,6 +94,9 @@ public class AccountsControllerService( string accessToken = await tokensService.CreateAccessTokenAsync(token.Account); + token.Account.LastActive = DateTime.UtcNow; + await database.SaveChangesAsync(); + logger.LogInformation($"Account with ID {token.AccountId} was authenticated by token refreshing"); return RequestResult.Ok(new AuthenticateResponse { diff --git a/WatchIt.Website/WatchIt.Website/App.razor b/WatchIt.Website/WatchIt.Website/App.razor index e5cba46..502723d 100644 --- a/WatchIt.Website/WatchIt.Website/App.razor +++ b/WatchIt.Website/WatchIt.Website/App.razor @@ -13,7 +13,7 @@ - + diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ItemPageHeaderPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ItemPageHeaderPanelComponent.razor index 689936a..12bbc20 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ItemPageHeaderPanelComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ItemPageHeaderPanelComponent.razor @@ -1,4 +1,4 @@ -