redirect to correct dashboard
This commit is contained in:
		
							parent
							
								
									31abd12d46
								
							
						
					
					
						commit
						d490a3c97c
					
				| @ -1,3 +1,4 @@ | ||||
| using System.Text.Json; | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| using Microsoft.AspNetCore.Mvc.RazorPages; | ||||
| 
 | ||||
| @ -6,8 +7,13 @@ namespace EnotaryoPH.Web.Pages | ||||
|     public class IndexModel : PageModel | ||||
|     { | ||||
|         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() | ||||
|         { | ||||
| @ -16,10 +22,15 @@ namespace EnotaryoPH.Web.Pages | ||||
|                 return Page(); | ||||
|             } | ||||
| 
 | ||||
|             if (_currentUserService.GetRole() == "Principal") | ||||
|             var role = _currentUserService.GetRole(); | ||||
|             if (role == nameof(UserType.Principal)) | ||||
|             { | ||||
|                 return RedirectToPage("/Principal/Dashboard/Dashboard"); | ||||
|             } | ||||
|             else if (role == nameof(UserType.Notary)) | ||||
|             { | ||||
|                 return RedirectToPage("/Notary/Dashboard/Dashboard"); | ||||
|             } | ||||
| 
 | ||||
|             return Page(); | ||||
|         } | ||||
|  | ||||
| @ -54,7 +54,7 @@ namespace EnotaryoPH.Web.Pages | ||||
|             }); | ||||
| 
 | ||||
|             var returnUrl = Request.Query["ReturnUrl"].ToString() ?? string.Empty; | ||||
|             return RedirectToPage(string.IsNullOrEmpty(returnUrl) ? "/Principal/Dashboard/Dashboard" : returnUrl); | ||||
|             return Redirect(string.IsNullOrEmpty(returnUrl) ? "/" : returnUrl); | ||||
|         } | ||||
| 
 | ||||
|         [Required] | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user