pub struct EmailVerificationPlugin { /* private fields */ }Expand description
Email verification plugin for handling email verification flows
Implementations§
Source§impl EmailVerificationPlugin
impl EmailVerificationPlugin
pub fn new() -> Self
pub fn with_config(config: EmailVerificationConfig) -> Self
pub fn verification_token_expiry(self, val: Duration) -> Self
pub fn send_email_notifications(self, val: bool) -> Self
pub fn require_verification_for_signin(self, val: bool) -> Self
pub fn auto_verify_new_users(self, val: bool) -> Self
pub fn send_on_sign_in(self, val: bool) -> Self
pub fn auto_sign_in_after_verification(self, val: bool) -> Self
pub fn before_email_verification(self, val: EmailVerificationHook) -> Self
pub fn after_email_verification(self, val: EmailVerificationHook) -> Self
Source§impl EmailVerificationPlugin
impl EmailVerificationPlugin
Sourcepub fn verification_token_expiry_hours(self, hours: i64) -> Self
pub fn verification_token_expiry_hours(self, hours: i64) -> Self
Backward-compatible builder: set token expiry in hours.
pub fn custom_send_verification_email( self, sender: Arc<dyn SendVerificationEmail>, ) -> Self
Source§impl EmailVerificationPlugin
impl EmailVerificationPlugin
Sourcepub async fn send_verification_on_sign_in<DB: DatabaseAdapter>(
&self,
user: &DB::User,
callback_url: Option<&str>,
ctx: &AuthContext<DB>,
) -> AuthResult<()>
pub async fn send_verification_on_sign_in<DB: DatabaseAdapter>( &self, user: &DB::User, callback_url: Option<&str>, ctx: &AuthContext<DB>, ) -> AuthResult<()>
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: DatabaseAdapter> AuthPlugin<DB> for EmailVerificationPlugin
impl<DB: DatabaseAdapter> AuthPlugin<DB> for EmailVerificationPlugin
Source§fn on_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 AuthRequest,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<AuthResponse>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 AuthRequest,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<AuthResponse>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: '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::User,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = AuthResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_user_created<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user: &'life1 DB::User,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = AuthResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: '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
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