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:
@@ -10,3 +10,5 @@
|
||||
- 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
|
||||
- checkbox and toggle disabled states
|
||||
- 404
|
||||
@@ -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>;
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user