Search code examples
asp.net-coreasp.net-identity

How to add : "config.SignIn.RequireConfirmedEmail = true;" Extended ApplicationUser


I want to add in : config.SignIn.RequireConfirmedEmail = true; to my startup code in .net core 2.2.

The example given by Microsoft shows how to do it for the stock standard identity user, but I have extended the user and it is now ApplicationUser.

services.AddIdentity<ApplicationUser, ApplicationRole>(               
    options => options.Stores.MaxLengthForKeys = 128
);

But in Microsoft example, it is like this (see below) which does not suit my needs...

   services.AddDefaultIdentity<IdentityUser>(config =>
    {
      config.SignIn.RequireConfirmedEmail = true;
    })

How do I include this in my code using config ?


Solution

  • Try this code:

    services.AddIdentity<ApplicationUser, ApplicationRole>(options =>
    {
        options.Stores.MaxLengthForKeys = 128;
        options.SignIn.RequireConfirmedEmail = true;
    });