Ask for the passkey again
use auth_chad::axum::FreshLogin;
async fn delete_account(fresh: FreshLogin<300>) -> String {
format!("{} proved it in the last 5 minutes", fresh.0.user())
}
More than 900 seconds does not compile. In the page:
import { stepUp } from "/auth/auth-chad.js";
button.onclick = async () => {
let res = await fetch("/account", { method: "DELETE" });
if (res.status === 401 && (await res.json()).error === "step_up_required") {
await stepUp("delete account");
res = await fetch("/account", { method: "DELETE" });
}
};
Inside the application, take Fresh<300> as an argument. Then no caller can forget the check:
use auth_chad::Fresh;
fn transfer(_proof: Fresh<300>, _to: &str) {}