AspNetCore.Identity - How to set LockoutEnabled = false for a new user

Viewed 808

I use Asp.Net Core Identity Nuget package for user management. But when I create a new user, its LockoutEnabled property will be set to "TRUE". This means a new user will be locked after successful create.

I've found this AllowedForNewUsers property but have no idea to set it to "FALSE".

How can I config to create a new user that not be locked? Or how can I set AllowedForNewUsers to "FALSE" in my project? Thanks.

1 Answers

As detailed in Configure ASP.NET Core Identity:

Lockout options are set in StartUp.ConfigureServices.

So you could do the following:

services.Configure<IdentityOptions>(options =>
{
    options.Lockout.AllowedForNewUsers = false;
});

This code specifies that a new user cannot be locked out.

Related