pub struct UserService<TAuthUser: AuthUser + Debug + Send + Sync> { /* private fields */ }
Expand description
Provides access logic for specified AuthUser
Implementations§
Source§impl<TAuthUser: AuthUser + Debug + Send + Sync> UserService<TAuthUser>
impl<TAuthUser: AuthUser + Debug + Send + Sync> UserService<TAuthUser>
Sourcepub async fn create_user(
&self,
username: String,
password: String,
) -> Result<i32, AuthError>
pub async fn create_user( &self, username: String, password: String, ) -> Result<i32, AuthError>
Creates new user and returns created id
Sourcepub async fn update_own_password(
&self,
access_token: &str,
old_password: &str,
new_password: String,
) -> Result<(), AuthError>
pub async fn update_own_password( &self, access_token: &str, old_password: &str, new_password: String, ) -> Result<(), AuthError>
Updates password for user with provided access_token
Sourcepub async fn update_other_user_password(
&self,
target_user_id: i32,
target_user_new_password: String,
) -> Result<(), AuthError>
pub async fn update_other_user_password( &self, target_user_id: i32, target_user_new_password: String, ) -> Result<(), AuthError>
Updates other user’s password
Note that this method doesn’t use CredentialValidator
for a new password validation to reset password to some default value for example
Also, this method is not recommended for self-update, use [update_own_password
] instead
Sourcepub async fn block_user(&self, username: &str) -> Result<(), AuthError>
pub async fn block_user(&self, username: &str) -> Result<(), AuthError>
Blocks user with provided username
Sourcepub async fn generate_tokens(
&self,
username: &str,
password: &str,
) -> Result<TokenPair, AuthError>
pub async fn generate_tokens( &self, username: &str, password: &str, ) -> Result<TokenPair, AuthError>
Generates TokenPair
(refresh and access tokens) by credentials
Sourcepub async fn refresh_tokens(
&self,
refresh_token: &str,
) -> Result<TokenPair, AuthError>
pub async fn refresh_tokens( &self, refresh_token: &str, ) -> Result<TokenPair, AuthError>
Refreshes TokenPair
by refresh token
Sourcepub async fn update_role_name(
&self,
role_id: i32,
new_name: String,
) -> Result<(), AuthError>
pub async fn update_role_name( &self, role_id: i32, new_name: String, ) -> Result<(), AuthError>
Updates role name
Auto Trait Implementations§
impl<TAuthUser> Freeze for UserService<TAuthUser>
impl<TAuthUser> !RefUnwindSafe for UserService<TAuthUser>
impl<TAuthUser> Send for UserService<TAuthUser>
impl<TAuthUser> Sync for UserService<TAuthUser>
impl<TAuthUser> Unpin for UserService<TAuthUser>
impl<TAuthUser> !UnwindSafe for UserService<TAuthUser>
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