mirror of
https://github.com/hpd840321/craftlabs-authorization-sdk.git
synced 2026-06-09 10:00:30 +08:00
feat(m11): add v-permission directive and button-level permission codes
This commit is contained in:
@@ -8,6 +8,7 @@ export const useAuthStore = defineStore("auth", {
|
||||
token: localStorage.getItem(TOKEN_KEY) || "",
|
||||
displayName: "",
|
||||
roles: [],
|
||||
permissions: [],
|
||||
}),
|
||||
getters: {
|
||||
hasAnyRole: (state) => {
|
||||
@@ -24,6 +25,7 @@ export const useAuthStore = defineStore("auth", {
|
||||
this.token = data.token;
|
||||
this.displayName = data.displayName || username;
|
||||
this.roles = data.roles || [];
|
||||
this.permissions = data.permissions || [];
|
||||
localStorage.setItem(TOKEN_KEY, this.token);
|
||||
axios.defaults.headers.common.Authorization = `Bearer ${this.token}`;
|
||||
},
|
||||
@@ -31,6 +33,7 @@ export const useAuthStore = defineStore("auth", {
|
||||
this.token = "";
|
||||
this.displayName = "";
|
||||
this.roles = [];
|
||||
this.permissions = [];
|
||||
localStorage.removeItem(TOKEN_KEY);
|
||||
delete axios.defaults.headers.common.Authorization;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user