/// <summary> /// Used by Default and AuthorizeUpgrade to render as per normal if there's no external login info, /// otherwise process the external login info. /// </summary> /// <returns></returns> private async Task<ActionResult> RenderDefaultOrProcessExternalLoginAsync( Func<ActionResult> defaultResponse, Func<ActionResult> externalSignInResponse) { if (defaultResponse == null) throw new ArgumentNullException("defaultResponse"); if (externalSignInResponse == null) throw new ArgumentNullException("externalSignInResponse"); ViewData.SetUmbracoPath(GlobalSettings.GetUmbracoMvcArea()); //check if there is the TempData with the any token name specified, if so, assign to view bag and render the view if (ViewData.FromTempData(TempData, ViewDataExtensions.TokenExternalSignInError) || ViewData.FromTempData(TempData, ViewDataExtensions.TokenPasswordResetCode)) return defaultResponse(); //First check if there's external login info, if there's not proceed as normal var loginInfo = await OwinContext.Authentication.GetExternalLoginInfoAsync( Constants.Security.BackOfficeExternalAuthenticationType); if (loginInfo == null || loginInfo.ExternalIdentity.IsAuthenticated == false) { return defaultResponse(); } //we're just logging in with an external source, not linking accounts return await ExternalSignInAsync(loginInfo, externalSignInResponse); }
/// <summary> /// Used by Default and AuthorizeUpgrade to render as per normal if there's no external login info, /// otherwise process the external login info. /// </summary> /// <returns></returns> private async Task <ActionResult> RenderDefaultOrProcessExternalLoginAsync( Func <ActionResult> defaultResponse, Func <ActionResult> externalSignInResponse) { if (defaultResponse == null) { throw new ArgumentNullException("defaultResponse"); } if (externalSignInResponse == null) { throw new ArgumentNullException("externalSignInResponse"); } ViewData.SetUmbracoPath(GlobalSettings.GetUmbracoMvcArea()); //check if there is the TempData or cookies with the any token name specified, if so, assign to view bag and render the view if (ViewData.FromBase64CookieData <BackOfficeExternalLoginProviderErrors>(HttpContext, ViewDataExtensions.TokenExternalSignInError) || ViewData.FromTempData(TempData, ViewDataExtensions.TokenExternalSignInError) || ViewData.FromTempData(TempData, ViewDataExtensions.TokenPasswordResetCode)) { return(defaultResponse()); } //First check if there's external login info, if there's not proceed as normal var loginInfo = await OwinContext.Authentication.GetExternalLoginInfoAsync( Constants.Security.BackOfficeExternalAuthenticationType); if (loginInfo == null || loginInfo.ExternalIdentity.IsAuthenticated == false) { // if the user is not logged in, check if there's any auto login redirects specified if (UmbracoContext.Security.ValidateCurrentUser(false) != ValidateRequestAttempt.Success) { var oauthRedirectAuthProvider = OwinContext.Authentication.GetAutoLoginProvider(); if (!oauthRedirectAuthProvider.IsNullOrWhiteSpace()) { return(ExternalLogin(oauthRedirectAuthProvider)); } } return(defaultResponse()); } //we're just logging in with an external source, not linking accounts return(await ExternalSignInAsync(loginInfo, externalSignInResponse)); }
/// <summary> /// Used by Default and AuthorizeUpgrade to render as per normal if there's no external login info, /// otherwise process the external login info. /// </summary> /// <returns></returns> private async Task <IActionResult> RenderDefaultOrProcessExternalLoginAsync( AuthenticateResult authenticateResult, Func <IActionResult> defaultResponse, Func <IActionResult> externalSignInResponse) { if (defaultResponse is null) { throw new ArgumentNullException(nameof(defaultResponse)); } if (externalSignInResponse is null) { throw new ArgumentNullException(nameof(externalSignInResponse)); } ViewData.SetUmbracoPath(_globalSettings.GetUmbracoMvcArea(_hostingEnvironment)); //check if there is the TempData or cookies with the any token name specified, if so, assign to view bag and render the view if (ViewData.FromBase64CookieData <BackOfficeExternalLoginProviderErrors>(_httpContextAccessor.HttpContext, ViewDataExtensions.TokenExternalSignInError, _jsonSerializer) || ViewData.FromTempData(TempData, ViewDataExtensions.TokenExternalSignInError) || ViewData.FromTempData(TempData, ViewDataExtensions.TokenPasswordResetCode)) { return(defaultResponse()); } //First check if there's external login info, if there's not proceed as normal var loginInfo = await _signInManager.GetExternalLoginInfoAsync(); if (loginInfo == null || loginInfo.Principal == null) { // if the user is not logged in, check if there's any auto login redirects specified if (!authenticateResult.Succeeded) { var oauthRedirectAuthProvider = _externalLogins.GetAutoLoginProvider(); if (!oauthRedirectAuthProvider.IsNullOrWhiteSpace()) { return(ExternalLogin(oauthRedirectAuthProvider)); } } return(defaultResponse()); } //we're just logging in with an external source, not linking accounts return(await ExternalSignInAsync(loginInfo, externalSignInResponse)); }