Skip to main content

Logout

Lagoon logout removes the access token from client browser storage and prevents its renewal from the refresh token. An already copied JWT access token remains valid until it expires.

Redirection after logout​

On the client side, override OnLogout in Main.cs to define the return page based on the page the user is logging out from.

Main.cs
protected override void OnLogout(LogoutEventArgs e)
{
// Si l'utilisateur se déconnecte depuis la page demo/showcase, on le renvoie vers cette page.
if (e.Pathname.Contains("demo/showcase"))
{
e.ReturnUrl = e.Pathname;
}
// Si l'utilisateur se déconnecte depuis la page counter, on le renvoie vers la page de connexion.
else if (e.Pathname.Contains("counter"))
{
e.ReturnUrl = "identity/account/login";
}
else
{
// Sinon, on conserve le comportement par défaut.
e.ReturnUrl = null;
}
}

LogoutEventArgs exposes:

PropertyDescription
PathnameCurrent relative path at the time of logout.
ReturnUrlReturn URL after logout.

Fixed redirection via configuration​

To always redirect to the same target after logout, configure PostLogoutUri in the application's appsettings.

appsettings.json
{
"App": {
"PostLogoutUri": "identity/account/login",
"PostLogoutMode": "Navigation"
}
}

PostLogoutMode accepts the following values:

ValueBehavior
NavigationNavigates to PostLogoutUri after logout.
XHRCalls PostLogoutUri asynchronously without using the result.

JWT tokens​

Note

JWT is stateless: the information needed for validation must be stored in the payload, avoiding a database query on every HTTP request. The access token's lifetime is 30 minutes by default and can be changed with AccessTokenLifetime.

Main.cs
protected override void OnConfigureAuthentification(AuthenticationOptions options)
{
// Durée de vie du jeton d'accès en secondes.
options.AccessTokenLifetime = 1800;
}