pub struct SessionIdentity {
pub user_id: String,
pub is_staff: bool,
pub is_superuser: bool,
}Expand description
Type-erased session identity, decoupled from the user’s concrete type.
Holds the minimal fields that CookieSessionAuthMiddleware reads from
SessionData.data: user_id, is_staff, is_superuser.
Fields§
§user_id: StringUser ID stored as "user_id" in session data.
is_staff: boolStaff flag stored as "is_staff" in session data.
is_superuser: boolSuperuser flag stored as "is_superuser" in session data.
Implementations§
Source§impl SessionIdentity
impl SessionIdentity
Sourcepub fn from_user(user: &impl ForceLoginUser) -> Self
pub fn from_user(user: &impl ForceLoginUser) -> Self
Extract identity from any user implementing ForceLoginUser.
Sourcepub fn to_session_data(&self, session_id: &str, ttl: Duration) -> SessionData
pub fn to_session_data(&self, session_id: &str, ttl: Duration) -> SessionData
Convert to SessionData for AsyncSessionBackend.
Creates a SessionData with the fields that CookieSessionAuthMiddleware
expects: user_id, is_staff, is_superuser.
Trait Implementations§
Source§impl Clone for SessionIdentity
impl Clone for SessionIdentity
Source§fn clone(&self) -> SessionIdentity
fn clone(&self) -> SessionIdentity
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SessionIdentity
impl Debug for SessionIdentity
Source§impl PartialEq for SessionIdentity
impl PartialEq for SessionIdentity
Source§fn eq(&self, other: &SessionIdentity) -> bool
fn eq(&self, other: &SessionIdentity) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for SessionIdentity
impl StructuralPartialEq for SessionIdentity
Auto Trait Implementations§
impl Freeze for SessionIdentity
impl RefUnwindSafe for SessionIdentity
impl Send for SessionIdentity
impl Sync for SessionIdentity
impl Unpin for SessionIdentity
impl UnsafeUnpin for SessionIdentity
impl UnwindSafe for SessionIdentity
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<E> ServerFnErrorAssertions<E> for Ewhere
E: Debug,
impl<E> ServerFnErrorAssertions<E> for Ewhere
E: Debug,
Source§fn should_contain_message(&self, expected: &str)where
E: Display,
fn should_contain_message(&self, expected: &str)where
E: Display,
Assert that the error message contains the specified text.
Source§fn should_have_message(&self, expected: &str)where
E: Display,
fn should_have_message(&self, expected: &str)where
E: Display,
Assert that the error message matches exactly.