finalizare 1.0

This commit is contained in:
andrei-mihnea-cerbu
2024-05-21 12:10:53 +03:00
parent f7795f7519
commit 1cc1d34003
11268 changed files with 2102399 additions and 10909 deletions
+27
View File
@@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace HealthcareManagerUiWebAssem;
public class RoleBasedRedirect : ComponentBase
{
[CascadingParameter] private Task<AuthenticationState> authenticationStateTask { get; set; }
[Inject] private NavigationManager NavigationManager { get; set; }
protected override async Task OnInitializedAsync()
{
var authState = await authenticationStateTask;
var user = authState.User;
if (NavigationManager.Uri == NavigationManager.BaseUri)
if (user.Identity.IsAuthenticated)
{
// Perform redirection based on the user's role
if (user.IsInRole(UserRoles.Admin))
NavigationManager.NavigateTo("/admin/dashboard");
else if (user.IsInRole(UserRoles.Doctor))
NavigationManager.NavigateTo("/doctor/dashboard");
else if (user.IsInRole(UserRoles.Patient)) NavigationManager.NavigateTo("/patient/dashboard");
}
}
}