pub struct PhoneNumberPlugin { /* private fields */ }Expand description
Phone authentication backed by atomic, single-use verification records.
Implementations§
Source§impl PhoneNumberPlugin
impl PhoneNumberPlugin
Sourcepub fn callbacks<S: AuthSchema>(
self,
callbacks: PhoneNumberCallbacks<S>,
) -> impl AuthPlugin<S>
pub fn callbacks<S: AuthSchema>( self, callbacks: PhoneNumberCallbacks<S>, ) -> impl AuthPlugin<S>
Attach schema-aware callbacks after configuring the plugin options.
Source§impl PhoneNumberPlugin
impl PhoneNumberPlugin
Sourcepub fn otp_length(self, length: usize) -> Self
pub fn otp_length(self, length: usize) -> Self
Set the generated decimal code length; the default is six digits.
Sourcepub fn expires_in(self, seconds: f64) -> Self
pub fn expires_in(self, seconds: f64) -> Self
Set code validity in seconds, including fractional values; the default is 300. An explicit zero remains zero.
Sourcepub fn allowed_attempts(self, attempts: u64) -> Self
pub fn allowed_attempts(self, attempts: u64) -> Self
Set the incorrect attempt budget; the default is three.
Sourcepub fn require_verification(self, require: bool) -> Self
pub fn require_verification(self, require: bool) -> Self
Require a verified number before password sign-in.
Sourcepub fn sign_up_on_verification(
self,
email: impl Fn(&str) -> String + Send + Sync + 'static,
) -> Self
pub fn sign_up_on_verification( self, email: impl Fn(&str) -> String + Send + Sync + 'static, ) -> Self
Create users after successful verification with the supplied temporary email.
Sourcepub fn temporary_name(
self,
name: impl Fn(&str) -> String + Send + Sync + 'static,
) -> Self
pub fn temporary_name( self, name: impl Fn(&str) -> String + Send + Sync + 'static, ) -> Self
Generate names for new users; the default name is the phone number.
Sourcepub fn send_otp<F, Fut>(self, callback: F) -> Selfwhere
F: Fn(PhoneOtp, AuthRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AuthResult<()>> + Send + 'static,
pub fn send_otp<F, Fut>(self, callback: F) -> Selfwhere
F: Fn(PhoneOtp, AuthRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AuthResult<()>> + Send + 'static,
Deliver verification codes through the application’s SMS provider.
Sourcepub fn send_password_reset_otp<F, Fut>(self, callback: F) -> Selfwhere
F: Fn(PhoneOtp, AuthRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AuthResult<()>> + Send + 'static,
pub fn send_password_reset_otp<F, Fut>(self, callback: F) -> Selfwhere
F: Fn(PhoneOtp, AuthRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AuthResult<()>> + Send + 'static,
Deliver password reset codes for registered phone numbers.
Sourcepub fn verify_otp<F, Fut>(self, callback: F) -> Selfwhere
F: Fn(PhoneOtp, AuthRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AuthResult<bool>> + Send + 'static,
pub fn verify_otp<F, Fut>(self, callback: F) -> Selfwhere
F: Fn(PhoneOtp, AuthRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AuthResult<bool>> + Send + 'static,
Delegate phone verification to the SMS provider instead of checking a stored code.
Sourcepub fn phone_number_validator<F, Fut>(self, callback: F) -> Self
pub fn phone_number_validator<F, Fut>(self, callback: F) -> Self
Validate numbers before sending verification codes or accepting password sign-in.
Sourcepub fn callback_on_verification<F, Fut>(self, callback: F) -> Selfwhere
F: Fn(PhoneVerification, AuthRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AuthResult<()>> + Send + 'static,
pub fn callback_on_verification<F, Fut>(self, callback: F) -> Selfwhere
F: Fn(PhoneVerification, AuthRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AuthResult<()>> + Send + 'static,
Run after persisting the verified user and before returning or issuing a session.
Sourcepub async fn consume_otp(
&self,
ctx: &AuthContext<impl AuthSchema>,
req: &AuthRequest,
otp: PhoneOtp,
) -> AuthResult<()>
pub async fn consume_otp( &self, ctx: &AuthContext<impl AuthSchema>, req: &AuthRequest, otp: PhoneOtp, ) -> AuthResult<()>
Consume an OTP without updating a user or creating a session.