Skip to main content

Email-only authentication

Lagoon can identify users solely by their email address. In this mode, the login workflow looks up the user by Email instead of UserName.

Configuration steps​

Model project​

In the Model project:

  1. edit ApplicationDbContext.cs;
  2. remove the call to SetUserNameRequired(builder); in OnModelCreating;
  3. edit the ApplicationUser model to expose the UserName and NormalizedUserName properties so they are populated with the value of Email.
Migration required

After these model changes, generate an EF Core migration and apply it according to your application's procedure.

Server project​

In the Server project, configure the authentication context in Main.cs.

Main.cs
protected override void OnConfigureAuthenticationContext(AuthenticationContext context)
{
// Identifie l'utilisateur avec la propriété Email.
context.IsEmailLogin = true;
}

Effect of IsEmailLogin​

When IsEmailLogin is true, Lagoon resolves the user using the email address carried by the authentication context.

ValueLookup used
trueLookup by Email.
falseLookup by UserName.
Default value

The authentication context initializes IsEmailLogin to true for an SSO identity and to false for other modes. An application can override this value in OnConfigureAuthenticationContext.