redirect to Principal Dashboard
This commit is contained in:
parent
1b17da99b0
commit
729f91a183
@ -11,6 +11,8 @@ namespace EnotaryoPH.Web.Common.Services
|
|||||||
|
|
||||||
public string? GetEmail() => _user.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Email)?.Value;
|
public string? GetEmail() => _user.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Email)?.Value;
|
||||||
|
|
||||||
|
public string? GetRole() => _user.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value;
|
||||||
|
|
||||||
public Guid GetUser_UID()
|
public Guid GetUser_UID()
|
||||||
{
|
{
|
||||||
if (_user == null)
|
if (_user == null)
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
|
namespace EnotaryoPH.Web.Common.Services
|
||||||
namespace EnotaryoPH.Web.Common.Services
|
|
||||||
{
|
{
|
||||||
public interface ICurrentUserService
|
public interface ICurrentUserService
|
||||||
{
|
{
|
||||||
string? GetEmail();
|
string? GetEmail();
|
||||||
|
|
||||||
|
string? GetRole();
|
||||||
|
|
||||||
Guid GetUser_UID();
|
Guid GetUser_UID();
|
||||||
|
|
||||||
bool IsAuthenticated();
|
bool IsAuthenticated();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
@ -1,21 +1,27 @@
|
|||||||
using EnotaryoPH.Data;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
|
||||||
namespace EnotaryoPH.Web.Pages
|
namespace EnotaryoPH.Web.Pages
|
||||||
{
|
{
|
||||||
public class IndexModel : PageModel
|
public class IndexModel : PageModel
|
||||||
{
|
{
|
||||||
private readonly ILogger<IndexModel> _logger;
|
private readonly ICurrentUserService _currentUserService;
|
||||||
private readonly NotaryoDBContext _notaryoDBContext;
|
|
||||||
|
|
||||||
public IndexModel(ILogger<IndexModel> logger, NotaryoDBContext notaryoDBContext)
|
public IndexModel(ICurrentUserService currentUserService) => _currentUserService = currentUserService;
|
||||||
|
|
||||||
|
public IActionResult OnGet()
|
||||||
{
|
{
|
||||||
_logger = logger;
|
if (_currentUserService.IsAuthenticated() == false)
|
||||||
_notaryoDBContext = notaryoDBContext;
|
{
|
||||||
|
return Page();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnGet()
|
if (_currentUserService.GetRole() == "Principal")
|
||||||
{
|
{
|
||||||
|
return RedirectToPage("/Principal/Dashboard/Dashboard");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Page();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user