Trait humphrey_auth::database::AuthDatabase
source · pub trait AuthDatabase {
// Required methods
fn get_user_by_uid(&self, uid: impl AsRef<str>) -> Option<User>;
fn get_user_by_token(&self, token: impl AsRef<str>) -> Option<User>;
fn get_session_by_token(&self, token: impl AsRef<str>) -> Option<Session>;
fn update_user(&mut self, user: User) -> Result<(), AuthError>;
fn add_user(&mut self, user: User) -> Result<(), AuthError>;
fn remove_user(&mut self, uid: impl AsRef<str>) -> Result<(), AuthError>;
}
Expand description
Represents a database which can be used to store auth information. Must be implemented for whatever database you are using.
It is good practice to have a separate collection for authentication information and user details, so whatever collection/table you use in your implementation of this trait should ideally not be used for anything else.
Required Methods§
sourcefn get_user_by_uid(&self, uid: impl AsRef<str>) -> Option<User>
fn get_user_by_uid(&self, uid: impl AsRef<str>) -> Option<User>
Returns the user associated with the given UID, or None
if not found.
sourcefn get_user_by_token(&self, token: impl AsRef<str>) -> Option<User>
fn get_user_by_token(&self, token: impl AsRef<str>) -> Option<User>
Returns the user who owns the given token, or None
if not found.
sourcefn get_session_by_token(&self, token: impl AsRef<str>) -> Option<Session>
fn get_session_by_token(&self, token: impl AsRef<str>) -> Option<Session>
Returns the session identified by the given token, or None
if not found.
Object Safety§
This trait is not object safe.