@fishawack/lab-velocity 1.4.7 → 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.
@@ -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,20 +35,33 @@ 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: {
41
45
  getUser({ commit }, { errors, query = "" }) {
42
46
  return axios
43
- .get(`/api/user/self${query}`, {
47
+ .get(`/api/users/self${query}`, {
44
48
  params: {
45
49
  include: "company"
46
50
  }
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,10 +70,11 @@ 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");
62
77
  },
63
78
  },
64
79
  };
65
- export default store;
80
+ export default store;
@@ -12,7 +12,7 @@ axios.interceptors.request.use(
12
12
 
13
13
  axios.interceptors.response.use(
14
14
  response => {
15
- return response;
15
+ return response;
16
16
  },
17
17
  error => {
18
18
  return Promise.resolve(error);
@@ -24,7 +24,7 @@ function retrieveResponse(request) {
24
24
  }
25
25
 
26
26
  const fakes = {
27
- "/api/user/self": {
27
+ "/api/users/self": {
28
28
  "get" : {
29
29
  "data":{
30
30
  "id": 2,
@@ -81,4 +81,4 @@ const fakes = {
81
81
  "two_factor": false
82
82
  }
83
83
  }
84
- }
84
+ }
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ### What
4
4
 
5
- Avalere Health branded style system
5
+ Avalere Health branded style system
6
6
 
7
7
  ### Why
8
8
 
@@ -15,3 +15,54 @@ Prevent code repetition.
15
15
  ```bash
16
16
  npm install @fishawack/lab-velocity
17
17
  ```
18
+
19
+
20
+ ### Auth Module
21
+ Frontend files to to work with the Hydrate Module.
22
+ #### Installation
23
+
24
+ ##### Import Axios File
25
+ import axios from "axios";
26
+ import "@fishawack/lab-velocity/AuthModule/js/AuthAxios.js";
27
+
28
+ ##### Import Routes File
29
+ Inside Router.js file
30
+ import { authRoutes, configureRoutes } from "@fishawack/lab-velocity/AuthModule/js/AuthRoutes";
31
+
32
+ let routes = require("./routes.js")(null, store).concat(authRoutes(null,store,store.state.auth.authBase));
33
+ Add routes to createRouter call
34
+
35
+ add method call after createRouter
36
+ configureRoutes(router);
37
+ ##### Import Store
38
+ import AuthStore from "@fishawack/lab-velocity/AuthModule/js/AuthStore.js";
39
+ Inside createStore method add
40
+ modules: {
41
+ auth: AuthStore
42
+ },
43
+ Inside VuexPersistedState add
44
+ paths:["auth"]
45
+
46
+ At bottom of file set
47
+ window.store = store;
48
+ ##### SVGS
49
+ Ensure Content has Velocity pulled in
50
+ {
51
+ "lftp": "ftp-fishawack.egnyte.com",
52
+ "location": "Shared/FW/Knutsford/Digital/Auto-Content/Lab/Velocity"
53
+ }
54
+ Copy out the svg folder contents into the svg files within vue.
55
+
56
+ ##### ENV VARS
57
+ HYDRATE_LOGO=example-logo
58
+ HYDRATE_REDIRECT=index
59
+
60
+ HYDRATE_LOGO=example-logo(No Default set, name of svg logo to display on page)
61
+ HYDRATE_ROUTE=(Default auth if not configured)
62
+ HYDRATE_REDIRECT=(Default index if not configured)
63
+ HYDRATE_ADMIN=true (DO NOT use unless on Admin site and want to disable auth flows and only use sso login)
64
+ HYDRATE_CONTACT=(Default mailto:EP@avalerehealth, Email for contact us button)
65
+
66
+ ##### Verify dependencies are installed
67
+ Axios
68
+ form-backend-validation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishawack/lab-velocity",
3
- "version": "1.4.7",
3
+ "version": "1.5.0",
4
4
  "description": "Avalere Health branded style system",
5
5
  "scripts": {
6
6
  "setup": "npm ci || npm i && npm run content",