Skip to content

Latest commit

 

History

History
 
 

username-or-email

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Sign In and Sign Up with Username or Email

This sample combines the UX of both the Email and Username based journeys. The sample policy is based on SocialAndLocalAccounts starter pack.

Live demo

To check out the user experience of using Email, follow these steps:

  1. Create an account using the B2C_1A_Demo_SignUp_UsernameOrEmail policy. For the sign-in name, type a valid email address, such as [email protected]. Select Continue to complete the sign-up process. In the next page you will be asked to verify your email address (you can't change the email), and fill out the password and your name.
  2. Sign-in using the B2C_1A_Demo_SignIn_UsernameOrEmail policy, with the Email you registered. Note, the user experience for this policy is identical to the username.
  3. Reset your password using the B2C_1A_Demo_PasswordReset_UsernameOrEmail policy. In the first page type your email, then select continue. On the next page you will be asked to verify your email.

To check out the user experience of using Username, follow these steps:

  1. Create an account using the B2C_1A_Demo_SignUp_UsernameOrEmail policy. For the sign-in name, type a valid email address, such as emily. Select Continue to complete the sign-up process. In the next page you will be asked to provide and verify your email address and fill out the password and your name. The username is presented on the top of the sign-up page (you can change it).
  2. Sign-in using the B2C_1A_Demo_SignIn_UsernameOrEmail policy, with the Email you registered. Note, the user experience for this policy is identical to the Email.
  3. Reset your password using the B2C_1A_Demo_PasswordReset_UsernameOrEmail policy. In the first page type your username, then select continue. On the next page you will be asked to type your email address and verify it.

Prerequisites

How it works

Sign Up

During sign up, the user is presented with a page to enter their Username. Upon submitting this field, the regexAnalysisUsername validation technical profile will call the claims transformation isEmail.

isEmail claims transformation uses a regex to return a boolean isEmailBoolean if it detects an email format.

isEmailBoolean then is used to determine if the user will go through the Username based sign up or Email sign up. During Email based sign up, the user only needs to verify the email and provide any further details. During Username based sign up, the user will be created with the username as the identifier, and the verified email stored in the strongAuthenticationEmail field.

Sign In

During sign in, the user is presented with a page to enter their Username and Password as normal. B2C will lookup the account with either and authenticate the user as normal.

Password Reset

During password reset the user is presented with a page to enter their Username. Upon submitting this field, the regexAnalysisUsername validation technical profile will call the claims transformation isEmail.

isEmail claims transformation uses a regex to return a boolean isEmailBoolean if it detects an email format.

isEmailBoolean then is used to determine if the user will go through the Username based password reset or Email password reset. During Email based password reset, the user only verifies the email and after can change the password. During Username based password reset, the user will verify the email, and if the email matches that which was stored in strongAuthenticationEmail during sign up, then the user can reset the password.

Community Help and Support

Use Stack Overflow to get support from the community. Ask your questions on Stack Overflow first and browse existing issues to see if someone has asked your question before. Make sure that your questions or comments are tagged with [azure-ad-b2c].

If you find a bug in the sample, please raise the issue on GitHub Issues.

To provide product feedback, visit the Azure Active Directory B2C Feedback page.