mirror of
https://github.com/TheRealOwenRees/chess-scribe-website.git
synced 2026-07-23 01:46:57 +00:00
if no code is provided return 404
This commit is contained in:
@@ -9,4 +9,6 @@
|
|||||||
- 429 lichess error handling
|
- 429 lichess error handling
|
||||||
- add throw errors or return errors in server code
|
- add throw errors or return errors in server code
|
||||||
- try/catch where needed in client 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
|
||||||
@@ -6,6 +6,8 @@ const routeApi = getRouteApi("/callback");
|
|||||||
const Callback = () => {
|
const Callback = () => {
|
||||||
const { useLichessCallback } = useLichess();
|
const { useLichessCallback } = useLichess();
|
||||||
const { code } = routeApi.useSearch();
|
const { code } = routeApi.useSearch();
|
||||||
|
|
||||||
|
// TODO deal with error if code is invalid
|
||||||
useLichessCallback({ code }).then();
|
useLichessCallback({ code }).then();
|
||||||
|
|
||||||
return <div>Loading...</div>;
|
return <div>Loading...</div>;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute, notFound } from "@tanstack/react-router";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import Callback from "#/pages/Callback.tsx";
|
import Callback from "#/pages/Callback.tsx";
|
||||||
|
|
||||||
@@ -6,10 +6,14 @@ const callbackSchema = z.object({
|
|||||||
code: z.string(),
|
code: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// type CallbackProps = z.infer<typeof callbackSchema>;
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/callback")({
|
export const Route = createFileRoute("/callback")({
|
||||||
validateSearch: (search) => callbackSchema.parse(search),
|
validateSearch: (search) => callbackSchema.parse(search),
|
||||||
|
|
||||||
|
beforeLoad: ({ search }) => {
|
||||||
|
if (!search.code) {
|
||||||
|
throw notFound();
|
||||||
|
}
|
||||||
|
},
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user