diff options
Diffstat (limited to 'jb-ui/src/pages/MagicLink.tsx')
| -rw-r--r-- | jb-ui/src/pages/MagicLink.tsx | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/jb-ui/src/pages/MagicLink.tsx b/jb-ui/src/pages/MagicLink.tsx index 48d7dc5..e85bac3 100644 --- a/jb-ui/src/pages/MagicLink.tsx +++ b/jb-ui/src/pages/MagicLink.tsx @@ -5,6 +5,7 @@ type ExchangeState = "working" | "failed" | "missing"; const MagicLink = function () { const started = useRef(false); const [state, setState] = useState<ExchangeState>("working"); + const [errorMsg, setErrorMesg] = useState(""); useEffect(() => { // React Strict Mode runs effects twice in development. Never redeem twice. @@ -31,14 +32,19 @@ const MagicLink = function () { if (!response.ok) throw new Error("Magic-link exchange failed"); window.location.replace("/"); }) - .catch(() => setState("failed")); + .catch((err) => { + const response = err?.response?.data; + setErrorMesg(response?.detail ?? err.message); + setState("failed"); + }); }, []); if (state === "missing") { return <p>This login link is missing its token.</p>; } if (state === "failed") { - return <p>This login link is invalid or has expired.</p>; + return <p>{errorMsg}</p>; + // return <p>This login link is invalid or has expired.</p>; } return <p>Signing you in…</p>; }; |
