fix(login): readable email-OTP send error instead of raw '{}'
gotrue can throw an error whose message is an unhelpful JSON blob (e.g. 500 'Error sending magic link email' when Supabase SMTP isn't configured). Show a readable, actionable message instead of rendering the raw payload.
This commit is contained in:
@@ -454,7 +454,14 @@ function OtpVerify({ account, email, initialChannel = "email", remember, setReme
|
||||
if (!PHONE_RE.test(phone)) { setError("Enter your phone in international format, e.g. +14155550100."); return; }
|
||||
await sendPhoneOtp(phone); setSent(true);
|
||||
}
|
||||
} catch (e) { setError((e as Error).message); }
|
||||
} catch (e) {
|
||||
// gotrue can throw an error whose message is an unhelpful "{}"/JSON blob (e.g. a
|
||||
// 500 "Error sending magic link email" when SMTP isn't set up). Show something
|
||||
// readable and actionable instead of the raw payload.
|
||||
const raw = (e as { message?: unknown })?.message;
|
||||
const readable = typeof raw === "string" && raw.trim() && !raw.trim().startsWith("{") ? raw.trim() : "";
|
||||
setError(readable || "We couldn't send your sign-in code right now. Please try again shortly, or sign in with your password.");
|
||||
}
|
||||
}
|
||||
|
||||
async function complete(code: string) {
|
||||
|
||||
Reference in New Issue
Block a user