Files
front/stores/authStore.ts
T

25 lines
577 B
TypeScript

import { defineStore } from "pinia";
import { whoami } from "~/netcode";
export const useAuthStore = defineStore("auth", {
state: () => ({
selfUser: {} as { userId?: string; image?: string; username?: string },
logged: false,
}),
actions: {
async whoami() {
try {
const data = await whoami().then((data) => {
this.logged = true;
return data;
});
Object.assign(this.selfUser, data.value);
} catch (e) {}
},
oauth2_register_discord: () => {
throw Error("not implemented");
},
},
});