pub struct ModelUserProvider<E: EntityTrait> { /* private fields */ }Expand description
A generic UserProvider that loads a model by primary key.
Works for any entity whose Model is Authenticatable and whose primary
key is a single integer column (i32/i64). This removes the hand-written
provider apps otherwise need just to hydrate Auth::user() from the session.
ⓘ
use ferro_rs::{bind, ModelUserProvider, UserProvider};
// in bootstrap:
bind!(dyn UserProvider, ModelUserProvider::<crate::models::user::Entity>::default());Only retrieve_by_id is implemented;
credential lookup/validation use the trait defaults. For composite or
non-integer keys, or password login, implement UserProvider by hand.
Implementations§
Source§impl<E: EntityTrait> ModelUserProvider<E>
impl<E: EntityTrait> ModelUserProvider<E>
Trait Implementations§
Source§impl<E: EntityTrait> Default for ModelUserProvider<E>
impl<E: EntityTrait> Default for ModelUserProvider<E>
Source§impl<E> UserProvider for ModelUserProvider<E>where
E: EntityTrait + 'static,
E::Model: Authenticatable + Clone,
<E::PrimaryKey as PrimaryKeyTrait>::ValueType: TryFrom<i64> + Send,
impl<E> UserProvider for ModelUserProvider<E>where
E: EntityTrait + 'static,
E::Model: Authenticatable + Clone,
<E::PrimaryKey as PrimaryKeyTrait>::ValueType: TryFrom<i64> + Send,
Source§fn retrieve_by_id<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<Option<Arc<dyn Authenticatable>>, FrameworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn retrieve_by_id<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<Option<Arc<dyn Authenticatable>>, FrameworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieve a user by their unique identifier
Source§fn retrieve_by_credentials<'life0, 'life1, 'async_trait>(
&'life0 self,
_credentials: &'life1 Value,
) -> Pin<Box<dyn Future<Output = Result<Option<Arc<dyn Authenticatable>>, FrameworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn retrieve_by_credentials<'life0, 'life1, 'async_trait>(
&'life0 self,
_credentials: &'life1 Value,
) -> Pin<Box<dyn Future<Output = Result<Option<Arc<dyn Authenticatable>>, FrameworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve a user by credentials (for custom authentication flows) Read more
Source§fn validate_credentials<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_user: &'life1 dyn Authenticatable,
_credentials: &'life2 Value,
) -> Pin<Box<dyn Future<Output = Result<bool, FrameworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn validate_credentials<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_user: &'life1 dyn Authenticatable,
_credentials: &'life2 Value,
) -> Pin<Box<dyn Future<Output = Result<bool, FrameworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Validate credentials against a user Read more
Auto Trait Implementations§
impl<E> Freeze for ModelUserProvider<E>
impl<E> RefUnwindSafe for ModelUserProvider<E>
impl<E> Send for ModelUserProvider<E>
impl<E> Sync for ModelUserProvider<E>
impl<E> Unpin for ModelUserProvider<E>
impl<E> UnsafeUnpin for ModelUserProvider<E>
impl<E> UnwindSafe for ModelUserProvider<E>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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