Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cancel button throws error on Azure AD B2C SignUp

Tags:

azure-ad-b2c

we are using custom SignUpSignIn policy with social Idps and localAccount options.

when a user clicks on signUp and after entering some details in the form and then decides to cancel the process by clicking the "Cancel" button, we are getting an error

https://example.com/#error=access_denied&error_description=AADB2C90091%3a+The+user+has+cancelled+entering+self-asserted+information.%0d%0aCorrelation+ID%3a+c55fc20c-d296-42ed-8eea-2857d8d8d44b%0d%0a

Please let me know how to handle this in case of 1) local Account Registration 2) social Idp's (Facebook, Google..)

Can we do anything at the policy level or while registering the applications. Please let me know

Thanks,

like image 840
Lucky Avatar asked Apr 27 '18 17:04

Lucky


2 Answers

The idea behind getting those error codes is to catch them and redirect to where you consider. Could be again to the sign-up or sign-in page, etc.

like image 66
Marcelo P. Di Iorio - MSFT Avatar answered Sep 29 '22 10:09

Marcelo P. Di Iorio - MSFT


I believe the previous response is correct. The error is handled by the application based on the code sent back. For example, in an MVC app in the startup.auth.cs add the following to tell the application where to send the user:

 private Task AuthenticationFailed(AuthenticationFailedNotification<OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> notification)
        {
            notification.HandleResponse();
            if (notification.ProtocolMessage.ErrorDescription != null && notification.ProtocolMessage.ErrorDescription.Contains("AADB2C90091"))
            {
                // If the user clicked the cancel button, redirect to default route
                notification.Response.Redirect("/");
            }
            else 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("/Home/ResetPassword");
            }
            else if (notification.Exception != null && notification.Exception.Message == "access_denied")
            {
                notification.Response.Redirect("/");
            }
            else
            {
                notification.Response.Redirect("/Home/Error?message=" + notification.ProtocolMessage.ErrorDescription);
            }

            return Task.FromResult(0);
        }
like image 34
Amy Ruddy Avatar answered Sep 29 '22 08:09

Amy Ruddy