pub struct MagicLinkService<U: UserRepository, T: TokenRepository> { /* private fields */ }Expand description
Service for magic link authentication operations
Implementations§
Source§impl<U: UserRepository, T: TokenRepository> MagicLinkService<U, T>
impl<U: UserRepository, T: TokenRepository> MagicLinkService<U, T>
Sourcepub fn new(user_repository: Arc<U>, token_repository: Arc<T>) -> Self
pub fn new(user_repository: Arc<U>, token_repository: Arc<T>) -> Self
Create a new MagicLinkService with the given repositories
Sourcepub async fn generate_token(&self, email: &str) -> Result<SecureToken, Error>
pub async fn generate_token(&self, email: &str) -> Result<SecureToken, Error>
Generate a magic token for a user
Sourcepub async fn generate_token_with_expiration(
&self,
email: &str,
expires_in: Duration,
) -> Result<SecureToken, Error>
pub async fn generate_token_with_expiration( &self, email: &str, expires_in: Duration, ) -> Result<SecureToken, Error>
Generate a magic token with custom expiration
Sourcepub async fn verify_token(&self, token: &str) -> Result<Option<User>, Error>
pub async fn verify_token(&self, token: &str) -> Result<Option<User>, Error>
Verify a magic token and return the associated user
Sourcepub async fn cleanup_expired_tokens(&self) -> Result<(), Error>
pub async fn cleanup_expired_tokens(&self) -> Result<(), Error>
Clean up expired tokens
Auto Trait Implementations§
impl<U, T> Freeze for MagicLinkService<U, T>
impl<U, T> RefUnwindSafe for MagicLinkService<U, T>where
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<U, T> Send for MagicLinkService<U, T>
impl<U, T> Sync for MagicLinkService<U, T>
impl<U, T> Unpin for MagicLinkService<U, T>
impl<U, T> UnwindSafe for MagicLinkService<U, T>where
T: RefUnwindSafe,
U: RefUnwindSafe,
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