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