pub struct EmailVerificationPlugin { /* private fields */ }Expand description
Email verification plugin for handling email verification flows
Implementations§
Source§impl EmailVerificationPlugin
impl EmailVerificationPlugin
pub fn new() -> EmailVerificationPlugin
pub fn with_config(config: EmailVerificationConfig) -> EmailVerificationPlugin
pub fn verification_token_expiry( self, val: TimeDelta, ) -> EmailVerificationPlugin
pub fn send_email_notifications(self, val: bool) -> EmailVerificationPlugin
pub fn require_verification_for_signin( self, val: bool, ) -> EmailVerificationPlugin
pub fn auto_verify_new_users(self, val: bool) -> EmailVerificationPlugin
pub fn send_on_sign_in(self, val: bool) -> EmailVerificationPlugin
pub fn auto_sign_in_after_verification( self, val: bool, ) -> EmailVerificationPlugin
pub fn before_email_verification( self, val: Arc<dyn Fn(&User) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send>> + Send + Sync>, ) -> EmailVerificationPlugin
pub fn after_email_verification( self, val: Arc<dyn Fn(&User) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send>> + Send + Sync>, ) -> EmailVerificationPlugin
Source§impl EmailVerificationPlugin
impl EmailVerificationPlugin
Sourcepub fn verification_token_expiry_hours(
self,
hours: i64,
) -> EmailVerificationPlugin
pub fn verification_token_expiry_hours( self, hours: i64, ) -> EmailVerificationPlugin
Backward-compatible builder: set token expiry in hours.
pub fn custom_send_verification_email( self, sender: Arc<dyn SendVerificationEmail>, ) -> EmailVerificationPlugin
Source§impl EmailVerificationPlugin
impl EmailVerificationPlugin
Sourcepub async fn send_verification_on_sign_in<DB>(
&self,
user: &<DB as UserOps>::User,
callback_url: Option<&str>,
ctx: &AuthContext<DB>,
) -> Result<(), AuthError>where
DB: DatabaseAdapter,
pub async fn send_verification_on_sign_in<DB>(
&self,
user: &<DB as UserOps>::User,
callback_url: Option<&str>,
ctx: &AuthContext<DB>,
) -> Result<(), AuthError>where
DB: DatabaseAdapter,
Send a verification email on sign-in for an unverified user.
Callers (e.g. the sign-in plugin) should invoke this when
EmailVerificationConfig::send_on_sign_in is true and the user is
not yet verified.
Sourcepub fn should_send_on_sign_in(&self) -> bool
pub fn should_send_on_sign_in(&self) -> bool
Check if send_on_sign_in is enabled.
Sourcepub fn is_verification_required(&self) -> bool
pub fn is_verification_required(&self) -> bool
Check if email verification is required for signin
Sourcepub async fn is_user_verified_or_not_required(
&self,
user: &impl AuthUser,
) -> bool
pub async fn is_user_verified_or_not_required( &self, user: &impl AuthUser, ) -> bool
Check if user is verified or verification is not required
Trait Implementations§
Source§impl<DB> AuthPlugin<DB> for EmailVerificationPluginwhere
DB: DatabaseAdapter,
impl<DB> AuthPlugin<DB> for EmailVerificationPluginwhere
DB: DatabaseAdapter,
Source§fn on_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 AuthRequest,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<Option<AuthResponse>, AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
EmailVerificationPlugin: 'async_trait,
fn on_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 AuthRequest,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<Option<AuthResponse>, AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
EmailVerificationPlugin: 'async_trait,
Called for each request - return Some(response) to handle, None to pass through
Source§fn on_user_created<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user: &'life1 <DB as UserOps>::User,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
EmailVerificationPlugin: 'async_trait,
fn on_user_created<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user: &'life1 <DB as UserOps>::User,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
EmailVerificationPlugin: 'async_trait,
Called after a user is created
Source§fn on_init<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 mut AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn on_init<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 mut AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Called when the plugin is initialized
Source§fn before_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_req: &'life1 AuthRequest,
_ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<Option<BeforeRequestAction>, AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn before_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_req: &'life1 AuthRequest,
_ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<Option<BeforeRequestAction>, AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Called before route matching for every incoming request. Read more
Source§fn on_session_created<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session: &'life1 <DB as SessionOps>::Session,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn on_session_created<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session: &'life1 <DB as SessionOps>::Session,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Called after a session is created
Source§fn on_user_deleted<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn on_user_deleted<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Called before a user is deleted
Source§fn on_session_deleted<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_token: &'life1 str,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn on_session_deleted<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_token: &'life1 str,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Called before a session is deleted
Source§impl Default for EmailVerificationPlugin
impl Default for EmailVerificationPlugin
Source§fn default() -> EmailVerificationPlugin
fn default() -> EmailVerificationPlugin
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for EmailVerificationPlugin
impl !RefUnwindSafe for EmailVerificationPlugin
impl Send for EmailVerificationPlugin
impl Sync for EmailVerificationPlugin
impl Unpin for EmailVerificationPlugin
impl UnsafeUnpin for EmailVerificationPlugin
impl !UnwindSafe for EmailVerificationPlugin
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