Skip to main content

user

Function user 

Source
pub fn user<U: PanelUser>(cx: &Cx) -> Option<&U>
Expand description

The signed-in user, as the app’s own user type.

None when nobody is signed in to the request’s panel, and when the panel’s Authenticator loads another type than U — a helper shared by two panels with different user types answers None on the other one.

fn admins_only(cx: &Cx) -> bool {
    auth::user::<Staff>(cx).is_some_and(|staff| staff.admin)
}