Skip to main content

user

Function user 

Source
pub async fn user<U: Authenticatable>(
    session: &Session,
) -> Result<Option<U>, AppError>
Expand description

The current session’s authenticated user, if any (Laravel’s Auth::user()), resolved through U::GUARD’s own session slot - so user::<User>(&session) and user::<Admin>(&session) read independent login state even though they share one Session. Ok(None) covers both “not logged in” and “logged in as a user id that no longer exists”

  • both are “no current user”, not an error.