redirect to correct dashboard

This commit is contained in:
jojo aquino 2025-03-03 19:25:40 +00:00
parent 31abd12d46
commit d490a3c97c
2 changed files with 14 additions and 3 deletions

View File

@ -1,3 +1,4 @@
using System.Text.Json;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.RazorPages;
@ -6,8 +7,13 @@ namespace EnotaryoPH.Web.Pages
public class IndexModel : PageModel public class IndexModel : PageModel
{ {
private readonly ICurrentUserService _currentUserService; private readonly ICurrentUserService _currentUserService;
private readonly NotificationService _notificationService;
public IndexModel(ICurrentUserService currentUserService) => _currentUserService = currentUserService; public IndexModel(ICurrentUserService currentUserService, NotificationService notificationService)
{
_currentUserService = currentUserService;
_notificationService = notificationService;
}
public IActionResult OnGet() public IActionResult OnGet()
{ {
@ -16,10 +22,15 @@ namespace EnotaryoPH.Web.Pages
return Page(); return Page();
} }
if (_currentUserService.GetRole() == "Principal") var role = _currentUserService.GetRole();
if (role == nameof(UserType.Principal))
{ {
return RedirectToPage("/Principal/Dashboard/Dashboard"); return RedirectToPage("/Principal/Dashboard/Dashboard");
} }
else if (role == nameof(UserType.Notary))
{
return RedirectToPage("/Notary/Dashboard/Dashboard");
}
return Page(); return Page();
} }

View File

@ -54,7 +54,7 @@ namespace EnotaryoPH.Web.Pages
}); });
var returnUrl = Request.Query["ReturnUrl"].ToString() ?? string.Empty; var returnUrl = Request.Query["ReturnUrl"].ToString() ?? string.Empty;
return RedirectToPage(string.IsNullOrEmpty(returnUrl) ? "/Principal/Dashboard/Dashboard" : returnUrl); return Redirect(string.IsNullOrEmpty(returnUrl) ? "/" : returnUrl);
} }
[Required] [Required]