if no code is provided return 404

This commit is contained in:
2026-06-11 10:14:08 +02:00
parent 8d19564a4e
commit 5bf4ec95c8
3 changed files with 12 additions and 4 deletions
+3 -1
View File
@@ -9,4 +9,6 @@
- 429 lichess error handling
- add throw errors or return errors in server code
- try/catch where needed in client code
- generate state and check it against the state returned from lichess https://lichess.org/api#tag/oauth/GET/oauth
- generate state and check it against the state returned from lichess https://lichess.org/api#tag/oauth/GET/oauth
- checkbox and toggle disabled states
- 404
+2
View File
@@ -6,6 +6,8 @@ const routeApi = getRouteApi("/callback");
const Callback = () => {
const { useLichessCallback } = useLichess();
const { code } = routeApi.useSearch();
// TODO deal with error if code is invalid
useLichessCallback({ code }).then();
return <div>Loading...</div>;
+7 -3
View File
@@ -1,4 +1,4 @@
import { createFileRoute } from "@tanstack/react-router";
import { createFileRoute, notFound } from "@tanstack/react-router";
import { z } from "zod";
import Callback from "#/pages/Callback.tsx";
@@ -6,10 +6,14 @@ const callbackSchema = z.object({
code: z.string(),
});
// type CallbackProps = z.infer<typeof callbackSchema>;
export const Route = createFileRoute("/callback")({
validateSearch: (search) => callbackSchema.parse(search),
beforeLoad: ({ search }) => {
if (!search.code) {
throw notFound();
}
},
component: RouteComponent,
});