Something went wrong. Try again.
A free, open-source, self-hosted place to write a novel.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132/** * better-auth answers with its own words, in an `APIError` whose body carries a * code and a message. Reading them here keeps every page reporting the same * failure the same way. */export function messageFor( error: unknown, fallback = 'Something did not work. Try again.'): string { if (error && typeof error === 'object') { const body = (error as { body?: { message?: unknown } }).body;
if (body && typeof body.message === 'string' && body.message.length > 0) return body.message;
const message = (error as { message?: unknown }).message;
if (typeof message === 'string' && message.length > 0) return message; }
return fallback;}
/** * A disabled account is refused when its session is created, the one auth * failure with a different answer. */export function isDisabledAccount(error: unknown): boolean { const body = (error as { body?: { code?: unknown } } | null)?.body;
return body?.code === 'BANNED_USER';}