I'm using services.AddIdentityExpressAdminUiConfiguration()
from the IdentityExpress package. How do I specify SignIn.RequireConfirmedAccount
?
Normally this would be accomplished in the services.AddDefaultIdentity()
call, but since AddIdentityExpressAdminUiConfiguration()
adds the identity, I would end up with an exception if I did that.
Adding the following to ConfigureServices() does not work:
services.Configure<SignInOptions>(x => x.RequireConfirmedAccount = true).
because UserManager.Options.SignIn.RequireConfirmedAccount
is always false.
I accomplished this by adding the following to Configure()
:
app.ApplicationServices.GetRequiredService<IOptions<IdentityOptions>>().Value.SignIn.RequireConfirmedAccount = true;
This will also work for setting the password strength attributes, etc.
Attempting to set this inside ConfigureServices()
didn't work. I suspect it's being overriden by the logic inside AddIdentityExpressAdminUiConfiguration()