/// <summary> /// Handles the GET call. /// </summary> public IActionResult OnGet() { loginHelper = new WebLoginHelper(this.HttpContext, config); if (loginHelper.IsLoggedIn) { // Redirect to the main page. return(Redirect("/Index")); } else if (loginHelper.IsCallbackFromOAuthServer()) { loginHelper.ExchangeAuthorizationCodeForCredentials(); // Redirect to the main page. return(Redirect("/Index")); } else { // Redirect the user to the OAuth2 login page. return(loginHelper.RedirectUsertoOAuthServer()); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { // Initialize login helper only in the page load, otherwise session information // won't be available. if (loginHelper.IsLoggedIn) { // Redirect to the main page. Response.Redirect("/Default.aspx"); } else if (loginHelper.IsCallbackFromOAuthServer()) { loginHelper.ExchangeAuthorizationCodeForCredentials(); // Redirect to the main page. Response.Redirect("/Default.aspx"); } else { // Redirect the user to the OAuth2 login page. loginHelper.RedirectUsertoOAuthServer(); } }