@fishawack/lab-velocity 1.4.8 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AuthModule/js/AuthStore.js +16 -1
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ const store = {
|
|
|
9
9
|
forcePasswordChange: false,
|
|
10
10
|
intended: null,
|
|
11
11
|
user: null,
|
|
12
|
+
isSuperAdmin: false,
|
|
12
13
|
redirect: process.env.HYDRATE_REDIRECT ?? 'index',
|
|
13
14
|
autoLogin: process.env.HYDRATE_ADMIN === 'true' ? true: false,
|
|
14
15
|
}
|
|
@@ -34,7 +35,10 @@ const store = {
|
|
|
34
35
|
},
|
|
35
36
|
setForcePasswordChange(state, value) {
|
|
36
37
|
state.forcePasswordChange = value;
|
|
37
|
-
}
|
|
38
|
+
},
|
|
39
|
+
setIsSuperAdmin(state, value) {
|
|
40
|
+
state.isSuperAdmin = value;
|
|
41
|
+
},
|
|
38
42
|
},
|
|
39
43
|
|
|
40
44
|
actions: {
|
|
@@ -47,7 +51,17 @@ const store = {
|
|
|
47
51
|
})
|
|
48
52
|
.then((res) => {
|
|
49
53
|
commit("setUser", res.data.data);
|
|
54
|
+
|
|
55
|
+
const isSuperAdmin = (data) => {
|
|
56
|
+
const roles = data.roles.map(r => r.name);
|
|
57
|
+
const permissions = data.permissions.map(p => p.name);
|
|
58
|
+
|
|
59
|
+
return roles.includes('administrator') && permissions.includes('write content');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
commit("setIsSuperAdmin", isSuperAdmin(res.data.data));
|
|
50
63
|
commit("setForcePasswordChange",res.data.data?.force_password_change);
|
|
64
|
+
|
|
51
65
|
return res.data.data;
|
|
52
66
|
})
|
|
53
67
|
.catch(errors);
|
|
@@ -56,6 +70,7 @@ const store = {
|
|
|
56
70
|
logout({ commit }, { errors }) {
|
|
57
71
|
commit("setAuth", false);
|
|
58
72
|
commit("setUser", null);
|
|
73
|
+
commit("setIsSuperAdmin", false);
|
|
59
74
|
commit("setForcePasswordChange", false);
|
|
60
75
|
|
|
61
76
|
return axios.post("/logout");
|