Wip : Lobby
This commit is contained in:
+10
-6
@@ -25,16 +25,19 @@ export async function getLobby() {
|
||||
|
||||
export async function whoami() {
|
||||
const config = useRuntimeConfig();
|
||||
const req = useFetch<User>(new URL("/whoami", config.public.endpoint).href, {
|
||||
credentials: "include",
|
||||
});
|
||||
const req = await useFetch<User>(
|
||||
new URL("/whoami", config.public.endpoint).href,
|
||||
{
|
||||
credentials: "include",
|
||||
}
|
||||
);
|
||||
if (
|
||||
req.error.value?.statusCode &&
|
||||
[401].includes(req.error.value.statusCode)
|
||||
) {
|
||||
await navigateTo(config.public.discordLoginEndpoint, {
|
||||
external: true,
|
||||
});
|
||||
// await navigateTo(config.public.discordLoginEndpoint, {
|
||||
// external: true,
|
||||
// });
|
||||
throw new Error("You are not logged in");
|
||||
}
|
||||
if (req.error.value) {
|
||||
@@ -42,6 +45,7 @@ export async function whoami() {
|
||||
"Something went wrong while trying to get user information"
|
||||
);
|
||||
}
|
||||
|
||||
return req.data;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user