Skip to main content

RegistrationEmailVerification

Struct RegistrationEmailVerification 

Source
pub struct RegistrationEmailVerification<'a> { /* private fields */ }
Expand description

一次性验证码引擎:配置经 Tools 的 config 槽注入,投递器经 extension 槽注入。

Implementations§

Source§

impl<'a> RegistrationEmailVerification<'a>

Source

pub fn from_context(ctx: &'a ActionContext) -> Result<Self, BaseError>

从 Action 上下文的 Tools config 槽读取 EmailVerificationConfig 构建引擎。

Source

pub fn from_config( config: &'a EmailVerificationConfig, ) -> Result<Self, BaseError>

从显式配置构建引擎。

用于同一 Tools 中需要第二套验证码 key 域的场景(如邮箱换绑验证码, 与注册验证码的 Redis key 前缀和密钥隔离)。调用方保证该配置来自 独立注入的 config 槽,且与注册验证码的密钥不冲突。

Source

pub async fn request( &self, ctx: &ActionContext, email: &str, deliver: bool, ) -> Result<RegistrationEmailCodeAccepted, BaseError>

请求签发一枚验证码。

deliver = false 时(如身份已存在的防枚举场景)只消耗限额、不真实投递, 仍返回通用接受响应。

Source

pub async fn request_via( &self, ctx: &ActionContext, email: &str, deliver: bool, sender: &VerificationCodeSenderHandle, ) -> Result<RegistrationEmailCodeAccepted, BaseError>

与 Self::request 相同,但验证码经显式传入的投递器发送。

用于注册之外的验证码场景(如登录 MFA 备用邮箱验证码):邮件文案由 业务侧 VerificationCodeSender 决定,与注册投递器解耦;存储、限流、 冷却与防枚举语义与 Self::request 完全一致。

Source

pub async fn consume( &self, ctx: &ActionContext, email: &str, code: &str, ) -> Result<(), BaseError>

校验并原子消费一枚验证码;任何失败都返回统一的无效验证码错误。

Source

pub async fn verify_only( &self, ctx: &ActionContext, email: &str, code: &str, ) -> Result<(), BaseError>

只校验不消费一枚验证码;任何失败都返回统一的无效验证码错误。

供两段式登录的第一段使用:先确认验证码有效但不销毁,待第二因子 (如 TOTP)也通过后再由 Self::consume 完成原子消费。失败路径与 Self::consume 共享错误计数与上限销毁语义——错误尝试照常计数、 达上限即销毁,不存在不计次的暴力枚举旁路。

本接口不构成最终持有证明:验证码在 TTL 内仍可被消费。调用方在签发 任何凭据前必须以 Self::consume 完成原子消费。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more