public async Task <IActionResult> ProviderCallback(string provider) { var authProvider = _providerFactory.Get(provider); UserInformation user; try { var secret = HttpContext.Session.GetString("secret"); user = await authProvider.AuthenticateUser(Request, secret); } catch (Exception ex) when(!(ex is NogginNetCoreConfigException)) { var failInfo = new AuthenticationFailInformation(ex); return(await _loginHandler.FailedLoginFrom(provider, failInfo, HttpContext)); } var loginSuccess = !string.IsNullOrEmpty(user.Id); if (loginSuccess) { return(await _loginHandler.SuccessfulLoginFrom(provider, user, HttpContext)); } else { // todo: Get better fail info from provider var failInfo = new AuthenticationFailInformation("Could not authenticate", user); return(await _loginHandler.FailedLoginFrom(provider, failInfo, HttpContext)); } }
public Task <IActionResult> FailedLoginFrom(string provider, AuthenticationFailInformation failInfo, HttpContext context) { // Todo: Set Tempdata message and display message to user if (failInfo != null) { // Just throw exception for now throw new NogginNetCoreAuthException(failInfo.Reason); } // Nothing to await so just returning a task of our result return(Task.FromResult(new RedirectToActionResult("About", "Home", new { type = "failed" }) as IActionResult)); }