Skip to main content

retry_after_step_up

Function retry_after_step_up 

Source
pub async fn retry_after_step_up<T, E, F, Fut, R, RFut>(
    call: F,
    reprove: R,
) -> Result<T, E>
where E: StepUpError, F: FnMut() -> Fut, Fut: IntoFuture<Output = Result<T, E>>, R: FnOnce(StepUpRequired) -> RFut, RFut: Future<Output = bool>,
Expand description

Run call (a future, or anything .await takes, such as a generated RPC method’s call); when it fails with a step-up refusal, hand the refusal to reprove and, when that answers true (the caller authenticated again), run call once more and return what it gives, even a second step-up refusal. Never loops.

reprove answers false when the user declined or the re-proof failed; the first refusal is then returned unchanged. Any other error, and a success, is returned from the first call as it is.

let order = retry_after_step_up(
    || client.procedures().transfer(&args),
    |step_up| async move { session.reauthenticate(step_up.max_age).await.is_ok() },
)
.await?;