Using email addresses as your Sitecore username

Published by

on

Are you storing extranet users in the Sitecore database? Want the user to sign in with their email address to easily remember their username? By default, Sitecore doesn’t allow email address formats to be stored in the username field, but never fear, it can be done!

The Sitecore setting ‘AccountNameValidation‘ sets a regular expression that gets used to validate whether a provided username has a valid format. You can find more details on this setting via the Sitecore KB article: https://kb.sitecore.net/articles/259229

Note: I recommend using a patch configuration to change this value, as opposed to editing the Web.config as recommended by the KB article.

An easy regex that will let anything in is the following:

<setting name="AccountNameValidation" value=".+" />

You will likely also want to consider enforcing unique usernames on your membership provider. The requiresUniqueEmail attribute on your membership provider can be set to true. See Brian Caos blog for more details!

Uhhh… this post seems a LOT like Brian’s blog

Yup! Kudos to Brian for the great post. I’ll admit, this one is mostly for me to be able to quickly find the details next time I need it 🙂

3 responses to “Using email addresses as your Sitecore username”

  1. Rodrigo Peplau Avatar

    Hi Jason, you could also let the email at the Email field, which is not custom, then get the user by it. Like: System.Web.Security.Membership.GetUserNameByEmail

    See, err…. this John West’s post:
    http://www.sitecore.net/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2013/09/use-email-addresses-for-authentication-with-the-sitecore-aspnet-cms.aspx

    1. Jason St-Cyr Avatar

      Thanks Rodrigo! That’s a good one I didn’t know about.

  2. […] post USING EMAIL ADDRESSES AS YOUR SITECORE USERNAME is almost a clone of Brian’s post Sitecore allow email adress as user […]

Leave a comment

Create a website or blog at WordPress.com