pub struct RuniqueSessionStore { /* private fields */ }Expand description
Management of authenticated sessions in DB.
Does not implement tower_sessions::SessionStore — tower-sessions
continues to use the memory store for CSRF and anonymous sessions.
Called explicitly at login and logout.
Implementations§
Source§impl RuniqueSessionStore
impl RuniqueSessionStore
Sourcepub async fn create(
&self,
cookie_id: &str,
user_id: Pk,
session_id: &str,
expires_at: NaiveDateTime,
) -> Result<(), DbErr>
pub async fn create( &self, cookie_id: &str, user_id: Pk, session_id: &str, expires_at: NaiveDateTime, ) -> Result<(), DbErr>
Creates a DB entry for an authenticated session.
Sourcepub async fn delete(&self, cookie_id: &str) -> Result<(), DbErr>
pub async fn delete(&self, cookie_id: &str) -> Result<(), DbErr>
Deletes the DB session corresponding to the cookie_id (logout).
Sourcepub async fn invalidate_other_sessions(
&self,
user_id: Pk,
current_cookie_id: &str,
) -> Result<(), DbErr>
pub async fn invalidate_other_sessions( &self, user_id: Pk, current_cookie_id: &str, ) -> Result<(), DbErr>
Invalidates all sessions of a user except the current one (exclusive login).
Sourcepub async fn invalidate_all(&self, user_id: Pk) -> Result<(), DbErr>
pub async fn invalidate_all(&self, user_id: Pk) -> Result<(), DbErr>
Invalidates all sessions of a user (password change, etc.).
Returns the active session matching cookie_id, or None if absent/expired.
Sourcepub async fn upsert_session(
&self,
cookie_id: &str,
user_id: Pk,
expires_at: NaiveDateTime,
data: Option<String>,
) -> Result<(), DbErr>
pub async fn upsert_session( &self, cookie_id: &str, user_id: Pk, expires_at: NaiveDateTime, data: Option<String>, ) -> Result<(), DbErr>
Persists serialized session data for an existing row (no-op if not found). Creates or updates a session entry (upsert).
Used by CleaningMemoryStore::create() at response commit: the new cookie_id
may not have a DB record yet (e.g. after cycle_id()), so a plain UPDATE
would silently no-op. This method inserts when the record is absent.
Sourcepub fn spawn_cleanup(&self, period: Duration)
pub fn spawn_cleanup(&self, period: Duration)
Deletes expired sessions (should be called periodically).
Trait Implementations§
Source§impl Clone for RuniqueSessionStore
impl Clone for RuniqueSessionStore
Auto Trait Implementations§
impl !RefUnwindSafe for RuniqueSessionStore
impl !UnwindSafe for RuniqueSessionStore
impl Freeze for RuniqueSessionStore
impl Send for RuniqueSessionStore
impl Sync for RuniqueSessionStore
impl Unpin for RuniqueSessionStore
impl UnsafeUnpin for RuniqueSessionStore
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, T> ConvertInto<T> for Fwhere
T: ConvertFrom<F>,
impl<F, T> ConvertInto<T> for Fwhere
T: ConvertFrom<F>,
Source§fn convert_into(self) -> T
fn convert_into(self) -> T
Self to a value of type T.Source§impl<F, T> ConvertTryFrom<F> for Twhere
F: ConvertInto<T>,
impl<F, T> ConvertTryFrom<F> for Twhere
F: ConvertInto<T>,
Source§impl<F, T> ConvertTryInto<T> for Fwhere
T: ConvertTryFrom<F>,
impl<F, T> ConvertTryInto<T> for Fwhere
T: ConvertTryFrom<F>,
Source§type Error = <T as ConvertTryFrom<F>>::Error
type Error = <T as ConvertTryFrom<F>>::Error
Source§fn convert_try_into(self) -> Result<T, <T as ConvertTryFrom<F>>::Error>
fn convert_try_into(self) -> Result<T, <T as ConvertTryFrom<F>>::Error>
Self to a value of type T.impl<T> ErasedDestructor for Twhere
T: 'static,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> 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> ⓘ
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> ⓘ
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 more