Skip to main content

Module session

Module session 

Source
Expand description

User session, admin authentication, and authentication traits.

Structs§

CurrentUser
Authenticated user injected into request extensions.

Enums§

LoginError
Why login opened no session.

Functions§

is_authenticated
Checks if the user is authenticated.
login
Logs in a user: stores their id in the session (and renews the session id and the CSRF token). Their name, rights and account state are read from the database on each request (request.user), not stored here.
logout
Logs out a user — removes the memory session and the DB entry if provided. Does nothing when no one is logged in.
protect_session
Protects an anonymous session from cleanup.
set_auth_session_ttl_secs
Called once at build time. Idempotent. A second call with a different value (two apps in the same process) is logged, never swallowed.
unprotect_session
Removes manual protection from an anonymous session.