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:
- edit
ApplicationDbContext.cs; - remove the call to
SetUserNameRequired(builder);inOnModelCreating; - edit the
ApplicationUsermodel to expose theUserNameandNormalizedUserNameproperties so they are populated with the value ofEmail.
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.
| Value | Lookup used |
|---|---|
true | Lookup by Email. |
false | Lookup 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.