start frant 050228
This commit is contained in:
+7
-1
@@ -1,5 +1,5 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref, computed } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import type { User } from '@/api/auth';
|
||||
import { fetchMe } from '@/api/auth';
|
||||
|
||||
@@ -10,6 +10,9 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
const user = ref<User | null>(null);
|
||||
|
||||
const isLoggedIn = computed(() => Boolean(token.value));
|
||||
const isAdmin = computed(() => user.value?.role === 'admin');
|
||||
const isBusinessOwner = computed(() => user.value?.role === 'business_owner');
|
||||
const isCustomer = computed(() => user.value?.role === 'customer');
|
||||
|
||||
function setSession(accessToken: string, profile: User) {
|
||||
token.value = accessToken;
|
||||
@@ -38,6 +41,9 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
token,
|
||||
user,
|
||||
isLoggedIn,
|
||||
isAdmin,
|
||||
isBusinessOwner,
|
||||
isCustomer,
|
||||
setSession,
|
||||
logout,
|
||||
loadUser,
|
||||
|
||||
Reference in New Issue
Block a user