Trait actix_plus_auth::DataProvider[][src]

pub trait DataProvider: Clone {
    type AccountType: Account;
#[must_use]    fn insert_account<'life0, 'async_trait>(
        &'life0 self,
        account: Self::AccountType,
        password_hash: String
    ) -> Pin<Box<dyn Future<Output = ResponseResult<Self::AccountType>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn fetch_account<'life0, 'life1, 'async_trait>(
        &'life0 self,
        email: &'life1 str
    ) -> Pin<Box<dyn Future<Output = ResponseResult<Option<(Self::AccountType, String)>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; }

A struct that implements this trait provides the functions that Actix+Auth needs to interact with your database (or flatfile, volatile storage in ram, whatever you want) to implement authentication. Although it is not strictly required to work at small scale, it is strongly recommended that the email of each account be able to be looked up quickly in a case-insensitive manner. With a SQL database, this can be accomplished by adding an index on the lowercase of the email. The email is also the primary key. Note that when this struct is cloned it should refer to the same datastore. This struct is cloned like a database pool is in normal Actix.

Associated Types

Loading content...

Required methods

#[must_use]fn insert_account<'life0, 'async_trait>(
    &'life0 self,
    account: Self::AccountType,
    password_hash: String
) -> Pin<Box<dyn Future<Output = ResponseResult<Self::AccountType>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Adds a new account to the database, then returns that account back. You may need to clone the account when implementing this function. If another account exists with this email, then the function should return some sort of error.

#[must_use]fn fetch_account<'life0, 'life1, 'async_trait>(
    &'life0 self,
    email: &'life1 str
) -> Pin<Box<dyn Future<Output = ResponseResult<Option<(Self::AccountType, String)>>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Fetches the account with the given email from the database, case-insensitively. Note that a lowercase email should be passed to this function, but the matching email as stored in the database may be in any case.

Loading content...

Implementors

Loading content...