Trait humphrey_auth::app::AuthState
source · pub trait AuthState<D>where
D: AuthDatabase,{
// Required method
fn auth_provider(&self) -> MutexGuard<'_, AuthProvider<D>>;
}
Expand description
Represents a state which contains an AuthProvider
.
This must be implemented on the state in order to use authentication.
Example
type DatabaseWrapper = Arc<RwLock<MyDatabase>>;
struct MyState {
db: DatabaseWrapper,
auth_provider: Mutex<AuthProvider<DatabaseWrapper>>
}
impl AuthState<DatabaseWrapper> for MyState {
fn auth_provider(&self) -> MutexGuard<AuthProvider<DatabaseWrapper>> {
self.auth_provider.lock().unwrap()
}
}
Required Methods§
sourcefn auth_provider(&self) -> MutexGuard<'_, AuthProvider<D>>
fn auth_provider(&self) -> MutexGuard<'_, AuthProvider<D>>
Returns a MutexGuard
to the AuthProvider
.