live · mainnetoc · docs
specs · api · guides
docs / documentation

@orangecheck/auth-client


@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

ParameterType
body| &#123; reason?: string; &#125; | null | undefined
argsOmit&lt;RedirectToSudoArgs, "returnTo"> & &#123; returnTo?: string; &#125;

Returns

boolean