pub struct PasswordResetService<S> { /* private fields */ }Expand description
Password reset service.
§Flow
- App calls
request_reset(email)→ gets a raw token (send it in the reset email yourself — authx does not send email). - User clicks link → app calls
reset_password(token, new_password).
Tokens expire after ttl (default 30 minutes) and are single-use.
Implementations§
Source§impl<S> PasswordResetService<S>
impl<S> PasswordResetService<S>
pub fn new(storage: S, events: EventBus) -> Self
pub fn with_ttl(self, ttl: Duration) -> Self
Sourcepub async fn request_reset(&self, email: &str) -> Result<Option<String>>
pub async fn request_reset(&self, email: &str) -> Result<Option<String>>
Issue a reset token for the given email.
Always succeeds (even for unknown emails) to avoid user enumeration.
Returns None if the email is not registered — caller should silently
ignore and not reveal this to the client.
Sourcepub async fn reset_password(&self, req: PasswordResetRequest) -> Result<()>
pub async fn reset_password(&self, req: PasswordResetRequest) -> Result<()>
Consume the reset token and update the password.
Auto Trait Implementations§
impl<S> Freeze for PasswordResetService<S>where
S: Freeze,
impl<S> !RefUnwindSafe for PasswordResetService<S>
impl<S> Send for PasswordResetService<S>where
S: Send,
impl<S> Sync for PasswordResetService<S>where
S: Sync,
impl<S> Unpin for PasswordResetService<S>where
S: Unpin,
impl<S> UnsafeUnpin for PasswordResetService<S>where
S: UnsafeUnpin,
impl<S> !UnwindSafe for PasswordResetService<S>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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