Example #1
0
        /*
         * Catch any failures received by the authentication middleware and handle appropriately
         */
        private Task OnAuthenticationFailed(AuthenticationFailedNotification <Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> notification)
        {
            if (notification.Exception.Message.StartsWith("OICE_20004") ||
                notification.Exception.Message.Contains("IDX10311"))
            {
                notification.SkipToNextMiddleware(); return(Task.FromResult(0));
            }

            notification.HandleResponse();

            // Handle the error code that Azure AD B2C throws when trying to reset a password from the login page
            // because password reset is not supported by a "sign-up or sign-in policy"
            if (notification.ProtocolMessage.ErrorDescription != null && notification.ProtocolMessage.ErrorDescription.Contains("AADB2C90118"))
            {
                // If the user clicked the reset password link, redirect to the reset password route
                notification.Response.Redirect("/Account/ResetPassword");
            }
            else if (notification.Exception.Message == "access_denied")
            {
                notification.Response.Redirect("/");
            }
            else
            {
                notification.Response.Redirect("/Home/Error?message=" + notification.Exception.Message);
            }

            return(Task.FromResult(0));
        }
Example #2
0
 private Task OnAuthenticationFailed(AuthenticationFailedNotification <OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> notification)
 {
     //notification.HandleResponse();
     //notification.Response.Redirect("/Error?message=" + notification.Exception.Message);
     //return Task.FromResult(0);
     if (!notification.Exception.Message.StartsWith("OICE_20004") &&
         !notification.Exception.Message.Contains("IDX10311"))
     {
         return(Task.FromResult(0));
     }
     notification.SkipToNextMiddleware(); return(Task.FromResult(0));
 }
Example #3
0
        private Task OnAuthenticationFailed(AuthenticationFailedNotification <OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> notification)
        {
            notification.HandleResponse();
            if (notification.Exception.Message.StartsWith("IDX10311"))
            {
                notification.SkipToNextMiddleware();
            }
            else
            {
                string i = notification.Exception.Message ?? "Error is null.";
                logger.Log(LogLevel.Error, "AuthenticationFailed Info: {0}", i);
            }

            return(Task.FromResult(0));
        }