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§
Required Methods§
sourcefn 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 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
sourcefn 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 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 useclock
: The clock to useemail
: The email to create the session foruser_agent
: The user agent of the browser which initiated the sessionip_address
: The IP address of the browser which initiated the session, if knownlocale
: The locale of the browser which initiated the session
§Errors
Returns Self::Error
if the underlying repository fails
sourcefn 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 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
sourcefn 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 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 useclock
: The clock to usesession
: The [UserRecoverySession
] to add the ticket touser_email
: The [UserEmail
] to add the ticket forticket
: The ticket to add
§Errors
Returns Self::Error
if the underlying repository fails
sourcefn 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,
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 consumptionticket
: The [UserRecoveryTicket
] to consumesession
: The [UserRecoverySession
] to mark as used
§Errors
Returns Self::Error
if the underlying repository fails or if the
recovery session was already used