@fishawack/lab-velocity 1.4.8 → 1.5.1

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.
@@ -125,6 +125,10 @@ export function authRoutes(node, store, nested = 'auth') {
125
125
  meta: {
126
126
  guest: true,
127
127
  },
128
+ },
129
+ {
130
+ path: '/callback',
131
+ redirect: `${nested}.callback`
128
132
  }]
129
133
  }
130
134
 
@@ -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,19 @@ 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("setAuth",true);
63
+
64
+ commit("setIsSuperAdmin", isSuperAdmin(res.data.data));
50
65
  commit("setForcePasswordChange",res.data.data?.force_password_change);
66
+
51
67
  return res.data.data;
52
68
  })
53
69
  .catch(errors);
@@ -56,6 +72,7 @@ const store = {
56
72
  logout({ commit }, { errors }) {
57
73
  commit("setAuth", false);
58
74
  commit("setUser", null);
75
+ commit("setIsSuperAdmin", false);
59
76
  commit("setForcePasswordChange", false);
60
77
 
61
78
  return axios.post("/logout");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishawack/lab-velocity",
3
- "version": "1.4.8",
3
+ "version": "1.5.1",
4
4
  "description": "Avalere Health branded style system",
5
5
  "scripts": {
6
6
  "setup": "npm ci || npm i && npm run content",