Home > OS >  Modify the username sign in custom policy to also accept email login
Modify the username sign in custom policy to also accept email login

Time:06-22

I need users to have unique usernames for my site, so I am using the sample policy here: https://github.com/azure-ad-b2c/samples/tree/master/policies/username-signup-or-signin/policy to do that. However, this sign in does not allow the users to later sign in with the email that they signed up with. Using the default email sign somehow does not work with accounts created with this, I suppose because it stores email where the policy I am using stores username. How can I make users able to log in with the email they put when signing up in addition to the username.

I would greatly appreciate some plug and play code if possible (minus the client id and other private info, of course. Please don't accidentally post that).

CodePudding user response:

That sample only allows usernames as you point out.

You need this sample that allows both.

Update

To log in with both, you need to link identities.

e.g. create the user with this:

"identities": [
  {
    "signInType": "userName",
    "issuer": "contoso.onmicrosoft.com",
    "issuerAssignedId": "johnsmith"
  },
  {
    "signInType": "emailAddress",
    "issuer": "contoso.onmicrosoft.com",
    "issuerAssignedId": "[email protected]"
  }  
]
  • Related