public async Task <IActionResult> Login() { try { logger.ScopeTrace(() => "Start login."); var sequenceData = await sequenceLogic.GetSequenceDataAsync <LoginUpSequenceData>(remove : false); loginPageLogic.CheckUpParty(sequenceData); var loginUpParty = await tenantRepository.GetAsync <LoginUpParty>(sequenceData.UpPartyId); securityHeaderLogic.AddImgSrc(loginUpParty.IconUrl); securityHeaderLogic.AddImgSrcFromCss(loginUpParty.Css); (var session, var user) = await sessionLogic.GetAndUpdateSessionCheckUserAsync(loginUpParty, GetDownPartyLink(loginUpParty, sequenceData)); var validSession = session != null && ValidSessionUpAgainstSequence(sequenceData, session, loginPageLogic.GetRequereMfa(user, loginUpParty, sequenceData)); if (validSession && sequenceData.LoginAction != LoginAction.RequireLogin) { return(await loginPageLogic.LoginResponseUpdateSessionAsync(loginUpParty, sequenceData.DownPartyLink, session)); } if (sequenceData.LoginAction == LoginAction.ReadSession) { return(await loginUpLogic.LoginResponseErrorAsync(sequenceData, LoginSequenceError.LoginRequired)); } else { logger.ScopeTrace(() => "Show login dialog."); return(View(nameof(Login), new LoginViewModel { SequenceString = SequenceString, Title = loginUpParty.Title, IconUrl = loginUpParty.IconUrl, Css = loginUpParty.Css, EnableCancelLogin = loginUpParty.EnableCancelLogin, EnableResetPassword = !loginUpParty.DisableResetPassword, EnableCreateUser = !validSession && loginUpParty.EnableCreateUser, Email = sequenceData.Email.IsNullOrWhiteSpace() ? string.Empty : sequenceData.Email, })); } } catch (Exception ex) { throw new EndpointException($"Login failed, Name '{RouteBinding.UpParty.Name}'.", ex) { RouteBinding = RouteBinding }; } }
public async Task <IActionResult> Login() { try { logger.ScopeTrace("Start login."); var sequenceData = await sequenceLogic.GetSequenceDataAsync <LoginUpSequenceData>(remove : false); CheckUpParty(sequenceData); var loginUpParty = await tenantRepository.GetAsync <LoginUpParty>(sequenceData.UpPartyId); var session = await sessionLogic.GetAndUpdateSessionCheckUserAsync(loginUpParty, GetDownPartyLink(loginUpParty, sequenceData)); var validSession = ValidSession(sequenceData, session); if (validSession && sequenceData.LoginAction != LoginAction.RequireLogin) { return(await loginUpLogic.LoginResponseAsync(session.Claims.ToClaimList())); } if (sequenceData.LoginAction == LoginAction.ReadSession) { return(await loginUpLogic.LoginResponseErrorAsync(sequenceData, LoginSequenceError.LoginRequired)); } else { logger.ScopeTrace("Show login dialog."); return(View(nameof(Login), new LoginViewModel { SequenceString = SequenceString, CssStyle = loginUpParty.CssStyle, EnableCancelLogin = loginUpParty.EnableCancelLogin, EnableResetPassword = !loginUpParty.DisableResetPassword, EnableCreateUser = !validSession && loginUpParty.EnableCreateUser, Email = sequenceData.Email.IsNullOrWhiteSpace() ? string.Empty : sequenceData.Email, })); } } catch (Exception ex) { throw new EndpointException($"Login failed, Name '{RouteBinding.UpParty.Name}'.", ex) { RouteBinding = RouteBinding }; } }