Fixed auth, NAV, projecttypes,numberranges,tenant,textemplates
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { defineStore } from "pinia"
|
||||
import router from "#app/plugins/router";
|
||||
|
||||
export const useAuthStore = defineStore("auth", {
|
||||
state: () => ({
|
||||
@@ -7,6 +8,7 @@ export const useAuthStore = defineStore("auth", {
|
||||
tenants: [] as { tenant_id: string; role: string; tenants: { id: string; name: string } }[],
|
||||
permissions: [] as string[],
|
||||
activeTenant: null as any,
|
||||
activeTenantData: null as any,
|
||||
loading: true as boolean,
|
||||
}),
|
||||
|
||||
@@ -43,18 +45,25 @@ export const useAuthStore = defineStore("auth", {
|
||||
try {
|
||||
const me = await useNuxtApp().$api("/api/me", {
|
||||
headers: { Authorization: `Bearer ${jwt}`,
|
||||
context: {
|
||||
jwt
|
||||
}}
|
||||
context: {
|
||||
jwt
|
||||
}}
|
||||
})
|
||||
console.log(me)
|
||||
this.user = me.user
|
||||
this.permissions = me.permissions
|
||||
this.tenants = me.tenants
|
||||
|
||||
this.tenants.sort(function (a, b) {
|
||||
if (a.id < b.id) return -1
|
||||
if (a.id > b.id) return 1
|
||||
})
|
||||
|
||||
this.profile = me.profile
|
||||
|
||||
if(me.activeTenant) {
|
||||
this.activeTenant = me.activeTenant
|
||||
this.activeTenantData = me.tenants.find(i => i.id === me.activeTenant)
|
||||
this.loading = false
|
||||
|
||||
} else {
|
||||
@@ -75,6 +84,7 @@ export const useAuthStore = defineStore("auth", {
|
||||
})
|
||||
useCookie("token").value = token
|
||||
await this.init(token)
|
||||
navigateTo("/")
|
||||
},
|
||||
|
||||
hasPermission(key: string) {
|
||||
|
||||
Reference in New Issue
Block a user