@orangecheck/auth-client / handleSudoRequired
Function: handleSudoRequired()
function handleSudoRequired(body:
| {
reason?: string;
}
| null
| undefined, args?: Omit<RedirectToSudoArgs, "returnTo"> & {
returnTo?: string;
}): boolean;
Defined in: sudo.tsx:75
Convenience wrapper · the most common consumer pattern is "if the
fetch response's body has reason === 'sudo_required', redirect."
Use this to keep that idiom one line:
const r = await fetch(...); const j = await r.json(); if (handleSudoRequired(j, { purpose: 'register hardware key' })) return;
Returns true if a redirect happened (and the caller should
short-circuit), false otherwise.
Parameters
| Parameter | Type |
|---|---|
body | | { reason?: string; } | null | undefined |
args | Omit<RedirectToSudoArgs, "returnTo"> & { returnTo?: string; } |
Returns
boolean