Struct torrust_index_backend::services::authentication::Service
source · pub struct Service { /* private fields */ }
Implementations§
source§impl Service
impl Service
pub fn new( configuration: Arc<Configuration>, json_web_token: Arc<JsonWebToken>, user_repository: Arc<DbUserRepository>, user_profile_repository: Arc<DbUserProfileRepository>, user_authentication_repository: Arc<DbUserAuthenticationRepository> ) -> Self
sourcepub async fn login(
&self,
username: &str,
password: &str
) -> Result<(String, UserCompact), ServiceError>
pub async fn login( &self, username: &str, password: &str ) -> Result<(String, UserCompact), ServiceError>
Authenticate user with username and password. It returns a JWT token and a compact user profile.
Errors
It returns:
- A
ServiceError::WrongPasswordOrUsername
if unable to get user profile. - A
ServiceError::InternalServerError
if unable to get user authentication data from the user id. - A
ServiceError::EmailNotVerified
if the email should be, but is not verified. - An error if unable to verify the password.
- An error if unable to get the user data from the database.
sourcepub async fn renew_token(
&self,
token: &str
) -> Result<(String, UserCompact), ServiceError>
pub async fn renew_token( &self, token: &str ) -> Result<(String, UserCompact), ServiceError>
Renew a supplied JWT.
Errors
This function will return an error if:
- Unable to verify the supplied payload as a valid jwt.
- Unable to get user data from the database.
Auto Trait Implementations§
impl !RefUnwindSafe for Service
impl Send for Service
impl Sync for Service
impl Unpin for Service
impl !UnwindSafe for Service
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