20 lines
484 B
TypeScript
20 lines
484 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() {
|
|
const data = await whoami();
|
|
Object.assign(this.selfUser, data.value);
|
|
this.logged = true;
|
|
},
|
|
oauth2_register_discord: () => {
|
|
throw Error("not implemented");
|
|
},
|
|
},
|
|
});
|