3
votes

I need some help with this sample:

https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-rest-api-step-custom

I need to do the same but with signin policy, i need to validate the email with sql database and change a status column in database, and/or block access if the email is doesn't exist.

do you have some example for that?

Thanks

P.D: Excuse my english

2
Welcome to SO! Check out this post on how to as a question that is likely to be answered: stackoverflow.com/help/how-to-ask In this case you should show some attempt at solving the problem. - Robert Moskal

2 Answers

4
votes

The example you are pointing to is more useful for just retrieving additional claims for a user but not for validating the input. Since you are validating the email address, this example is more relevant:

Walkthrough: Integrate REST API claims exchanges in your Azure AD B2C user journey as validation on user input

This is what I would suggest:

  1. Host your database behind a Rest API so it can be called to validate the email address
  2. Create a technical profile using Web.TPEngine.Providers.RestfulProvider that calls into your Rest API (see the example I linked above)
  3. Add a ValidationTechnicalProfile to the SelfAssertedAttributeProvider technical profile that collects the email so it will validate it and show an error if validation fails

By adding validation such as this, the user will be blocked with an error message and will have the opportunity to fix the input (e.g. typos) and try again. You can also get additional claims about that email address from the Rest API by adding them in the OutputClaims of both the technical profiles.

You will need to determine whether this is the right place to change the flag in the DB or if that ought to be a separate operation. The reason is that if the user goes to the next step in the user journey and then abandons it and comes back later, what would their experience be.

If you want it as a separate step later in the user journey, then you would create it using the example you provided (i.e. as a separate step after all the required steps have executed in the user journey).

2
votes

The steps will be very similar except you will need to modify a different UserJourney and RelyingParty.

Update <UserJourney Id="SignUpOrSignIn"> as described in step 4.

Update SignUpOrSignin.xml as described in step 5.