| 54 | }, [userCode]); |
| 55 | |
| 56 | const decide = async (accept: boolean) => { |
| 57 | setBusy(accept ? "approve" : "deny"); |
| 58 | setError(null); |
| 59 | const res = await fetch( |
| 60 | `${globalThis.location.origin}/api/auth/device/${accept ? "approve" : "deny"}`, |
| 61 | { |
| 62 | method: "POST", |
| 63 | credentials: "include", |
| 64 | headers: { "content-type": "application/json" }, |
| 65 | body: JSON.stringify({ userCode }), |
| 66 | }, |
| 67 | ); |
| 68 | setBusy(null); |
| 69 | if (!res.ok) { |
| 70 | setError("Could not record your decision. The code may have expired, try again."); |
| 71 | return; |
| 72 | } |
| 73 | setPhase(accept ? "approved" : "denied"); |
| 74 | }; |
| 75 | |
| 76 | return ( |
| 77 | <div className="flex min-h-screen items-center justify-center bg-background p-6"> |