20260715221223
This commit is contained in:
1 parent
7049584d1e
commit
704dda07b5
21 files changed
+2649
-427
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import { computed, ref } from "vue";
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
export const useAuthStore = defineStore(
|
||||
"auth",
|
||||
() => {
|
||||
const token = ref("");
|
||||
const orgid = ref("");
|
||||
const user = ref(null);
|
||||
const isAuthenticated = computed(() => Boolean(token.value));
|
||||
|
||||
function setSession(payload, organization) {
|
||||
token.value = payload.token ?? payload.access_token ?? "";
|
||||
orgid.value = payload.orgid ?? organization;
|
||||
user.value = payload.user ?? payload.user_info ?? null;
|
||||
}
|
||||
|
||||
function clearSession() {
|
||||
token.value = "";
|
||||
orgid.value = "";
|
||||
user.value = null;
|
||||
}
|
||||
|
||||
return {
|
||||
token,
|
||||
orgid,
|
||||
user,
|
||||
isAuthenticated,
|
||||
setSession,
|
||||
clearSession,
|
||||
};
|
||||
},
|
||||
{
|
||||
persist: {
|
||||
key: "fms-auth",
|
||||
pick: ["token", "orgid", "user"],
|
||||
},
|
||||
},
|
||||
);
|
||||
Reference in new issue
Block a user