public IActionResult Index() { string code = this.User.FindFirst(ClaimTypes.NameIdentifier).Value; if (code == null) { return(RedirectToAction(nameof(HomeController.Index), _flightSpannersData.ControllerName(nameof(HomeController)), new { area = nameof(CommonArea) })); } else { return(View(nameof(PersonalDataController.Index), _organizerDataViewModel)); } }
public IActionResult Index(string returnUrl) //To pass ReturnUrl value from view to controller. { //To pass ReturnUrl value from controller to view, ViewData's life only lasts during current http request. ViewData["ReturnUrl"] = returnUrl; if (User.Identity.IsAuthenticated) { if ((returnUrl != null) && Url.IsLocalUrl(returnUrl)) // To protecting against open redirect attacks { return(Redirect(returnUrl)); } //if the Role is spanner else if (this.User.FindFirst(ClaimTypes.Role).Value.ToLower().Equals("spanner")) { return(RedirectToAction(nameof(PersonalDataController.Index), _flightSpannersData.ControllerName(nameof(PersonalDataController)), new { area = nameof(SpannerArea) })); //return Content("Spanner Personal Data"); } //if the Role is organizer else if (this.User.FindFirst(ClaimTypes.Role).Value.ToLower().Equals("organizer")) { return(RedirectToAction(nameof(PersonalDataController.Index), _flightSpannersData.ControllerName(nameof(PersonalDataController)), new { area = nameof(OrganizerArea) })); } } // To set the error that gives that the user authintication has been end required to be sign in // , the error only displayed if the returnUrl is not null and not from SignOut get request if ((returnUrl != null) && !returnUrl.ToLower().EndsWith("signout") && Url.IsLocalUrl(returnUrl)) // To protecting against open redirect attacks { //Transfer the error message of user authentication end requires sign in //To pass error value from controller to view, ViewBag's life only lasts during current http request. ViewBag.error = "Your authentication ends, It is required to Sign in again!"; } //Returns to Index view of home controller. return(View(nameof(HomeController.Index), new IndexViewModel())); }
public IActionResult Index(int?page) { string code = this.User.FindFirst(ClaimTypes.NameIdentifier).Value; if (code == null) { return(RedirectToAction(nameof(HomeController.Index), _flightSpannersData.ControllerName(nameof(HomeController)), new { area = nameof(CommonArea) })); } else { //page ?? 1 {null coalescing operator} ==> return the valur of page if it has a value //,or return 1 if page is null _approvalsDataViewModel.SetApprovalsDataViewModelProperties(page ?? 1); return(View(nameof(ApprovalsDataController.Index), _approvalsDataViewModel)); } }