Feat : add login button

This commit is contained in:
2024-08-01 19:48:15 +02:00
parent f9197d470e
commit 7713faa4d0
6 changed files with 215 additions and 219 deletions
+2 -19
View File
@@ -9,29 +9,12 @@ export function subscribe(endpoint: string) {
return evtSource;
}
export async function getLobby() {
export async function whoami() {
const config = useRuntimeConfig();
const req = await useFetch<Array<Game>>(config.public.endpoint + "/games", {
const req = await useFetch<User>(config.public.endpoint + "/whoami", {
credentials: "include",
server: false,
});
// await req.execute();
await req.execute();
if (req.data.value == null) {
throw new Error("Lobby answer is empty");
}
return req.data as Ref<Game[]>;
}
export async function whoami() {
const config = useRuntimeConfig();
const req = await useFetch<User>(
config.public.endpoint + "/whoami",
{
credentials: "include",
server: false,
}
);
await req.execute();
if (req.error.value && req.error.value.statusCode == 401) {
// await navigateTo(config.public.discordLoginEndpoint, {