Trait mas_storage::user::UserRecoveryRepository

source ·
pub trait UserRecoveryRepository: Send + Sync {
    type Error;

    // Required methods
    fn lookup_session<'life0, 'async_trait>(
        &'life0 mut self,
        id: Ulid,
    ) -> Pin<Box<dyn Future<Output = Result<Option<UserRecoverySession>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn add_session<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        rng: &'life1 mut (dyn RngCore + Send),
        clock: &'life2 dyn Clock,
        email: String,
        user_agent: UserAgent,
        ip_address: Option<IpAddr>,
        locale: String,
    ) -> Pin<Box<dyn Future<Output = Result<UserRecoverySession, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn find_ticket<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        ticket: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<UserRecoveryTicket>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn add_ticket<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 mut self,
        rng: &'life1 mut (dyn RngCore + Send),
        clock: &'life2 dyn Clock,
        user_recovery_session: &'life3 UserRecoverySession,
        user_email: &'life4 UserEmail,
        ticket: String,
    ) -> Pin<Box<dyn Future<Output = Result<UserRecoveryTicket, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn consume_ticket<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        clock: &'life1 dyn Clock,
        user_recovery_ticket: UserRecoveryTicket,
        user_recovery_session: UserRecoverySession,
    ) -> Pin<Box<dyn Future<Output = Result<UserRecoverySession, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A UserRecoveryRepository helps interacting with [UserRecoverySession] and [UserRecoveryTicket] saved in the storage backend

Required Associated Types§

source

type Error

The error type returned by the repository

Required Methods§

source

fn lookup_session<'life0, 'async_trait>( &'life0 mut self, id: Ulid, ) -> Pin<Box<dyn Future<Output = Result<Option<UserRecoverySession>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lookup an [UserRecoverySession] by its ID

Returns None if no [UserRecoverySession] was found

§Parameters
  • id: The ID of the [UserRecoverySession] to lookup
§Errors

Returns Self::Error if the underlying repository fails

source

fn add_session<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, email: String, user_agent: UserAgent, ip_address: Option<IpAddr>, locale: String, ) -> Pin<Box<dyn Future<Output = Result<UserRecoverySession, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Create a new [UserRecoverySession] for the given email

Returns the newly created [UserRecoverySession]

§Parameters
  • rng: The random number generator to use
  • clock: The clock to use
  • email: The email to create the session for
  • user_agent: The user agent of the browser which initiated the session
  • ip_address: The IP address of the browser which initiated the session, if known
  • locale: The locale of the browser which initiated the session
§Errors

Returns Self::Error if the underlying repository fails

source

fn find_ticket<'life0, 'life1, 'async_trait>( &'life0 mut self, ticket: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<UserRecoveryTicket>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Find a [UserRecoveryTicket] by its ticket

Returns None if no [UserRecoveryTicket] was found

§Parameters
  • ticket: The ticket of the [UserRecoveryTicket] to lookup
§Errors

Returns Self::Error if the underlying repository fails

source

fn add_ticket<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, user_recovery_session: &'life3 UserRecoverySession, user_email: &'life4 UserEmail, ticket: String, ) -> Pin<Box<dyn Future<Output = Result<UserRecoveryTicket, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Add a [UserRecoveryTicket] to the given [UserRecoverySession] for the given [UserEmail]

§Parameters
  • rng: The random number generator to use
  • clock: The clock to use
  • session: The [UserRecoverySession] to add the ticket to
  • user_email: The [UserEmail] to add the ticket for
  • ticket: The ticket to add
§Errors

Returns Self::Error if the underlying repository fails

source

fn consume_ticket<'life0, 'life1, 'async_trait>( &'life0 mut self, clock: &'life1 dyn Clock, user_recovery_ticket: UserRecoveryTicket, user_recovery_session: UserRecoverySession, ) -> Pin<Box<dyn Future<Output = Result<UserRecoverySession, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Consume a [UserRecoveryTicket] and mark the session as used

§Parameters
  • clock: The clock to use to record the time of consumption
  • ticket: The [UserRecoveryTicket] to consume
  • session: The [UserRecoverySession] to mark as used
§Errors

Returns Self::Error if the underlying repository fails or if the recovery session was already used

Implementations on Foreign Types§

source§

impl<R> UserRecoveryRepository for Box<R>

§

type Error = <R as UserRecoveryRepository>::Error

source§

fn lookup_session<'life0, 'async_trait>( &'life0 mut self, id: Ulid, ) -> Pin<Box<dyn Future<Output = Result<Option<UserRecoverySession>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

fn add_session<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, email: String, user_agent: UserAgent, ip_address: Option<IpAddr>, locale: String, ) -> Pin<Box<dyn Future<Output = Result<UserRecoverySession, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

source§

fn find_ticket<'life0, 'life1, 'async_trait>( &'life0 mut self, ticket: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<UserRecoveryTicket>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

fn add_ticket<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, user_recovery_session: &'life3 UserRecoverySession, user_email: &'life4 UserEmail, ticket: String, ) -> Pin<Box<dyn Future<Output = Result<UserRecoveryTicket, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

source§

fn consume_ticket<'life0, 'life1, 'async_trait>( &'life0 mut self, clock: &'life1 dyn Clock, user_recovery_ticket: UserRecoveryTicket, user_recovery_session: UserRecoverySession, ) -> Pin<Box<dyn Future<Output = Result<UserRecoverySession, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§

source§

impl<R, F, E> UserRecoveryRepository for MapErr<R, F>

§

type Error = E