@fishawack/lab-velocity 1.2.1 → 1.2.2

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.
@@ -1,6 +1,6 @@
1
1
  import axios from "axios";
2
2
 
3
- export default function setAxiosDefaults() {
3
+ function setAxiosDefaults() {
4
4
  axios.defaults.baseURL = process.env.APP_URL;
5
5
  axios.defaults.withCredentials = true;
6
6
  axios.defaults.withXSRFToken = true;
@@ -22,4 +22,6 @@ axios.interceptors.response.use(null, (error) => {
22
22
  }
23
23
 
24
24
  return Promise.reject(error);
25
- });
25
+ });
26
+
27
+ setAxiosDefaults();
@@ -100,5 +100,57 @@ export function authRoutes(node, store, nested = 'auth') {
100
100
  footer: false,
101
101
  fullpageModal: true,
102
102
  },
103
+ },
104
+ {
105
+ path: "/admin",
106
+ redirect: () => {
107
+ const { authenticated } = store.state.auth;
108
+
109
+ if (!authenticated) {
110
+ store.commit("setAuth", true);
111
+ window.location = `${process.env.APP_URL}/login`;
112
+ } else {
113
+ window.location = `${process.env.APP_URL}/`;
114
+ }
115
+ },
116
+ name: "admin",
117
+ meta: {
118
+ guest: true,
119
+ },
103
120
  }]
121
+ }
122
+
123
+ export function configureRoutes(router) {
124
+
125
+ router.beforeEach((to, from, next) => {
126
+ const { authenticated, user, authBase, redirect } = store.state.auth;
127
+
128
+ const admin = to.path.includes("/admin");
129
+
130
+ if (to.query.verified) {
131
+ next({ name: `${authBase}.success-verify` });
132
+ } else if (authenticated) {
133
+ if (admin && !user?.admin) {
134
+ next({ name: redirect });
135
+ } else if (to.name === "login" || to.name === `${authBase}.login`) {
136
+ next({ name: redirect });
137
+ } else if (
138
+ !user?.email_verified_at &&
139
+ to.matched.some((d) => d.meta.guest) !== true
140
+ ) {
141
+ next({ name: `${authBase}.verify` });
142
+ } else {
143
+ next();
144
+ }
145
+ } else {
146
+ if (to.matched.some((d) => d.meta.guest) === true) {
147
+ next();
148
+ } else if (admin) {
149
+ next({ name: "login" });
150
+ } else {
151
+ next({ name: `${authBase}.login` });
152
+ }
153
+ }
154
+ });
155
+
104
156
  }
@@ -1,64 +1,58 @@
1
1
  "use strict";
2
2
  import axios from "axios";
3
- import { createStore } from "vuex";
4
- import VuexPersistedState from 'vuex-persistedstate';
5
3
 
6
- export function initAuthStore(store) {
4
+ const store = {
5
+ state() {
6
+ return {
7
+ authBase : process.env.HYDRATE_ROUTE ?? 'auth',
8
+ authenticated : false,
9
+ intended: null,
10
+ user: null,
11
+ redirect: process.env.HYDRATE_REDIRECT ?? 'index'
12
+ }
13
+ },
7
14
 
8
- store.registerModule('auth',{
9
- state() {
10
- return {
11
- authBase : process.env.HYDRATE_ROUTE ?? 'auth',
12
- authenticated : false,
13
- intended: null,
14
- user: null,
15
- redirect: process.env.HYDRATE_REDIRECT ?? 'index'
15
+ mutations: {
16
+ setAuth(state, value) {
17
+ state.authenticated = value;
18
+
19
+ if (!value) {
20
+ this.commit("setUser", null);
21
+ }
22
+ },
23
+ setUser(state, value) {
24
+ state.user = value;
25
+
26
+ if(window.dataLayer){
27
+ window.dataLayer.push({ event: "logic", user: value });
16
28
  }
17
29
  },
30
+ setIntended(state, value) {
31
+ state.intended = value;
32
+ },
33
+ },
18
34
 
19
- mutations: {
20
- setAuth(state, value) {
21
- state.authenticated = value;
22
-
23
- if (!value) {
24
- this.commit("setUser", null);
25
- }
26
- },
27
- setUser(state, value) {
28
- console.log("we are setting the user");
29
- console.log(value);
30
- state.user = value;
31
-
32
- if(window.dataLayer){
33
- window.dataLayer.push({ event: "logic", user: value });
34
- }
35
- },
36
- setIntended(state, value) {
37
- state.intended = value;
38
- },
35
+ actions: {
36
+ getUser({ commit }, { errors, query = "" }) {
37
+ return axios
38
+ .get(`/api/user/self${query}`, {
39
+ params: {
40
+ include: "company"
41
+ }
42
+ })
43
+ .then((res) => {
44
+ commit("setUser", res.data.data);
45
+ return res.data.data;
46
+ })
47
+ .catch(errors);
39
48
  },
40
49
 
41
- actions: {
42
- getUser({ commit }, { errors, query = "" }) {
43
- return axios
44
- .get(`/api/user/self${query}`, {
45
- params: {
46
- include: "company"
47
- }
48
- })
49
- .then((res) => {
50
- commit("setUser", res.data.data);
51
- return res.data.data;
52
- })
53
- .catch(errors);
54
- },
55
-
56
- logout({ commit }, { errors }) {
57
- commit("setAuth", false);
58
- commit("setUser", null);
59
-
60
- return axios.post("/logout");
61
- },
50
+ logout({ commit }, { errors }) {
51
+ commit("setAuth", false);
52
+ commit("setUser", null);
53
+
54
+ return axios.post("/logout");
62
55
  },
63
- });
64
- }
56
+ },
57
+ };
58
+ export default store;
@@ -61,7 +61,7 @@ export default {
61
61
  return {
62
62
  form: new Form(
63
63
  {
64
- email: this.$store.state.user?.email,
64
+ email: this.$store.state.auth.user?.email,
65
65
  password: '',
66
66
  },
67
67
  { resetOnSuccess: false }
@@ -117,8 +117,8 @@ export default {
117
117
  window.dataLayer.push({ event: "login", user });
118
118
  }
119
119
 
120
- if (this.$store.state.intended) {
121
- this.$router.push(this.$store.state.intended);
120
+ if (this.$store.state.auth.intended) {
121
+ this.$router.push(this.$store.state.auth.intended);
122
122
  } else {
123
123
  this.$router.push({ name: "members" });
124
124
  // Problem here
@@ -29,11 +29,10 @@ export default {
29
29
  window.dataLayer.push({ event: "login", user });
30
30
  }
31
31
 
32
- if (this.$store.state.intended) {
33
- this.$router.push(this.$store.state.intended);
32
+ if (this.$store.state.auth.intended) {
33
+ this.$router.push(this.$store.state.auth.intended);
34
34
  } else {
35
- this.$router.push({ name: "members" });
36
- // Problem Here
35
+ this.$router.push({ name: this.$store.state.auth.redirect });
37
36
  }
38
37
 
39
38
  this.$store.commit("setIntended", null);
@@ -129,8 +129,8 @@ export default {
129
129
  window.dataLayer.push({ event: "login", user });
130
130
  }
131
131
 
132
- if (this.$store.state.intended) {
133
- this.$router.push(this.$store.state.intended);
132
+ if (this.$store.state.auth.intended) {
133
+ this.$router.push(this.$store.state.auth.intended);
134
134
  } else {
135
135
  this.$router.push({ name: `${this.$store.state.auth.authBase}.verify` });
136
136
  // Problem Here
@@ -6,7 +6,7 @@
6
6
  background-color: black;
7
7
  height: 100vh;
8
8
  width: 100%;
9
- background: url('../media/content/images/hero-login-large.jpg') center top no-repeat;
9
+ background: url('../media/content/images/hero-auth-background-desktop.jpg') center top no-repeat;
10
10
  background-size: cover;
11
11
  z-index: 10;
12
12
 
@@ -14,6 +14,12 @@
14
14
  width: 13.3rem;
15
15
  z-index: 99;
16
16
  }
17
+ @include breakpoint (max-width $tabletMax) {
18
+ background: url('../media/content/images/hero-auth-background-tablet.jpg') center top no-repeat;
19
+ }
20
+ @include breakpoint (max-width $mobileMax) {
21
+ background: url('../media/content/images/hero-auth-background-mobile.jpg') center top no-repeat;
22
+ }
17
23
  }
18
24
 
19
25
  .AuthModule__form {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishawack/lab-velocity",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Avalere Health branded style system",
5
5
  "scripts": {
6
6
  "setup": "npm ci || npm i && npm run content",