basic login / logout lichess user

This commit is contained in:
2026-06-08 12:23:20 +02:00
parent ba05fbedd3
commit d1cdc7764b
7 changed files with 186 additions and 64 deletions
-33
View File
@@ -1,33 +0,0 @@
import { useServerFn } from "@tanstack/react-start";
import { useLichessUser } from "#/context/LichessUserContext.tsx";
import { getToken, login } from "#/server/lichess.ts";
export const useLichess = () => {
const { user, setUser, logout } = useLichessUser();
const triggerLogin = useServerFn(login);
const trigggerGetToken = useServerFn(getToken);
console.log("Lichess User:", user);
const lichessTokenVerification = async ({ code }) => {
await trigggerGetToken();
};
const lichessLogin = async () => {
// TODO add try/catch with toast
await triggerLogin();
};
const lichessLogout = () => {
console.log("Lichess Logout");
// TODO remove cookies
logout();
};
return {
lichessLogin,
lichessLogout,
lichessTokenVerification,
};
};