Skip to main content

UserStore

Trait UserStore 

Source
pub trait UserStore: Send + Sync {
    // Required methods
    fn find_by_email(&self, email: &str) -> Result<Option<AuthUser>, String>;
    fn find_by_id(&self, id: &str) -> Result<Option<AuthUser>, String>;
    fn create(
        &self,
        email: &str,
        password_hash: &str,
    ) -> Result<Option<AuthUser>, String>;
    fn set_password_hash(
        &self,
        id: &str,
        password_hash: &str,
    ) -> Result<(), String>;
    fn confirm(&self, id: &str) -> Result<(), String>;
}
Available on crate feature crypto and crate feature mailer and crate feature serde and non-WebAssembly only.
Expand description

Accounts: implement it over your users table, or use MemoryUserStore / DbUserStore. Errors are messages; the flows answer them 500. The methods are synchronous: the flows run as a middleware, on the blocking pool.

Required Methods§

Source

fn find_by_email(&self, email: &str) -> Result<Option<AuthUser>, String>

The account with this email (already lower-cased), if any.

Source

fn find_by_id(&self, id: &str) -> Result<Option<AuthUser>, String>

The account with this id, if any.

Source

fn create( &self, email: &str, password_hash: &str, ) -> Result<Option<AuthUser>, String>

Create an account (not confirmed). Ok(None) when the email is taken.

Source

fn set_password_hash(&self, id: &str, password_hash: &str) -> Result<(), String>

Replace the password hash.

Source

fn confirm(&self, id: &str) -> Result<(), String>

Mark the email address confirmed.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl UserStore for DbUserStore

Available on crate features model-mysql or model-postgres or model-sqlite only.
Source§

impl UserStore for MemoryUserStore