pub struct AuthService { /* private fields */ }Expand description
Authentication service
Implementations§
Source§impl AuthService
impl AuthService
Sourcepub fn with_expiration(self, expiration: Duration) -> Self
pub fn with_expiration(self, expiration: Duration) -> Self
Set custom token expiration
Sourcepub fn hash_password(&self, password: &str) -> Result<String>
pub fn hash_password(&self, password: &str) -> Result<String>
Hash a password using Argon2
Sourcepub fn verify_password(&self, password: &str, hash: &str) -> Result<bool>
pub fn verify_password(&self, password: &str, hash: &str) -> Result<bool>
Verify a password against a hash
Sourcepub fn generate_token(&self, user: &User) -> Result<Token>
pub fn generate_token(&self, user: &User) -> Result<Token>
Generate a JWT token for a user
Sourcepub fn verify_token(&self, token: &str) -> Result<Claims>
pub fn verify_token(&self, token: &str) -> Result<Claims>
Verify and decode a JWT token
Sourcepub fn create_session(&self, token: &str) -> Result<Session>
pub fn create_session(&self, token: &str) -> Result<Session>
Create a session from a token
Sourcepub fn generate_invitation_token(&self) -> String
pub fn generate_invitation_token(&self) -> String
Generate a random invitation token
Auto Trait Implementations§
impl Freeze for AuthService
impl RefUnwindSafe for AuthService
impl Send for AuthService
impl Sync for AuthService
impl Unpin for AuthService
impl UnwindSafe for AuthService
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
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>
Converts
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>
Converts
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