Project import from github
All checks were successful
Production Build and Deploy / Build (push) Successful in 1m7s
Production Build and Deploy / Deploy (push) Successful in 21s

This commit is contained in:
Liviu Burcusel 2026-01-14 16:29:05 +01:00
commit 0add58254d
Signed by: liviu
GPG key ID: 6CDB37A4AD2C610C
179 changed files with 23756 additions and 0 deletions

45
app/stores/auth.ts Normal file
View file

@ -0,0 +1,45 @@
import { defineStore } from "pinia";
import { ref, computed } from "vue";
import { createAuthClient } from "better-auth/vue";
const authClient = createAuthClient();
export const useAuthStore = defineStore("useAuthStore", () => {
const session = ref<Awaited<ReturnType<typeof authClient.useSession>> | null>(null);
const lastError = ref<string | undefined>(undefined);
async function init() {
const data = await authClient.useSession(useFetch);
session.value = data;
lastError.value = undefined;
}
const user = computed(() => session.value?.data?.user);
const loading = computed(() => session.value?.isPending);
async function signIn(email: string, password: string) {
const { error } = await authClient.signIn.email({
email,
password,
callbackURL: "/",
});
if (error) {
lastError.value = error.message;
}
}
async function signOut() {
await authClient.signOut({});
navigateTo("/");
}
return {
init,
lastError,
loading,
signIn,
signOut,
user,
};
});