Correct bunch of issues (#36)
All checks were successful
Game Ideas deploy / build-test-deploy (push) Successful in 1m28s

Reviewed-on: #36
This commit was merged in pull request #36.
This commit is contained in:
2025-04-29 23:49:11 +02:00
parent d3d16493e6
commit f3c9e1d9da
37 changed files with 246 additions and 186 deletions

View File

@@ -1,14 +1,19 @@
using GameIdeas.BlazorApp.Pages.Users.Filters;
using GameIdeas.BlazorApp.Pages.Users.Gateways;
using GameIdeas.BlazorApp.Shared.Components.Popup;
using GameIdeas.Shared.Constants;
using GameIdeas.Shared.Dto;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using System.Security.Claims;
namespace GameIdeas.BlazorApp.Pages.Users;
public partial class Users
{
[Inject] private IUserGateway UserGateway { get; set; } = default!;
[Inject] private AuthenticationStateProvider StateProvider { get; set; } = default!;
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
private Popup? Popup;
private bool IsLoading = false;
@@ -18,9 +23,19 @@ public partial class Users
private int CurrentPage = 1;
private UserDto UserAdd = new();
private UserDto? UserDelete;
private string? currentUserId;
protected override async Task OnInitializedAsync()
{
var authState = await StateProvider.GetAuthenticationStateAsync();
currentUserId = authState.User.FindFirstValue(ClaimTypes.Sid);
if (authState.User.FindFirstValue(ClaimTypes.Role) != GlobalConstants.ADMINISTRATOR || string.IsNullOrEmpty(currentUserId))
{
NavigationManager.NavigateTo("/Unauthorized");
return;
}
await FetchData();
await base.OnInitializedAsync();
}