Manguera v
Manguera v

Reputation: 482

How to store users with Unique Email in Identity

I want to force Identity to only store users with an unique email, otherwise don't allow it to register, and then recover the exception or error when i iterate through the errors of the result of the CreateAsync method. So How do i do this?

Upvotes: 0

Views: 660

Answers (1)

rabink
rabink

Reputation: 759

The default value for RequireUniqueEmail is false. You can overwrite it with true to enforce unique email.

services.Configure<IdentityOptions>(options =>
{
    //add this option to identity configuration
    options.User.RequireUniqueEmail = true;

});

Upvotes: 2

Related Questions