pub struct UseReverification { /* private fields */ }Expand description
Reactive handle returned by use_reverification, mirroring Clerk React’s
useReverification.
The handle is Copy, so it can be captured into event handlers. Wrap a
sensitive action with UseReverification::guard; if the action reports
that step-up reverification is needed, clerk-js’s reverification UI is shown
and the action resumes on success.
Implementations§
Source§impl UseReverification
impl UseReverification
Sourcepub async fn guard<T, F, Fut>(&self, action: F) -> Result<T, ClerkError>
pub async fn guard<T, F, Fut>(&self, action: F) -> Result<T, ClerkError>
Run a sensitive action, guarding it with step-up reverification.
action is the gated call. Typically it is a #[server] function that
maps a clerk reverification hint onto ClerkError::NeedsReverification
via ClerkError::from_reverification_hint; an action calling clerk-js
directly instead constructs that variant from its own caught throw. When
action reports that reverification is needed, clerk-js
prompts the user for a
fresh factor and action is retried on success. action may therefore
run twice, so it takes no arguments and is invoked fresh each time.
- action succeeds → its value
- action needs reverification, user completes it → the retry’s result
- action needs reverification, user cancels →
ClerkError::ReverificationCancelled - any other action error → propagated unchanged
§Example
use dioxus::prelude::*;
use dioxus_clerk::*;
#[component]
fn DangerZone() -> Element {
let reverify = use_reverification();
rsx! {
button {
onclick: move |_| async move {
let _ = reverify.guard(|| delete_account()).await;
},
"Delete account"
}
}
}Trait Implementations§
Source§impl Clone for UseReverification
impl Clone for UseReverification
Source§fn clone(&self) -> UseReverification
fn clone(&self) -> UseReverification
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more