@fishawack/lab-velocity 1.3.2 → 1.4.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.
|
@@ -24,6 +24,14 @@ export function authRoutes(node, store, nested = 'auth') {
|
|
|
24
24
|
.default,
|
|
25
25
|
name: `${nested}.login`
|
|
26
26
|
},
|
|
27
|
+
{
|
|
28
|
+
path: "force-login",
|
|
29
|
+
component: node
|
|
30
|
+
? ""
|
|
31
|
+
: require("../routes/loginheadless.vue")
|
|
32
|
+
.default,
|
|
33
|
+
name: `${nested}.force-login`
|
|
34
|
+
},
|
|
27
35
|
{
|
|
28
36
|
path: "callback",
|
|
29
37
|
component: node
|
|
@@ -123,7 +131,7 @@ export function authRoutes(node, store, nested = 'auth') {
|
|
|
123
131
|
export function configureRoutes(router) {
|
|
124
132
|
|
|
125
133
|
router.beforeEach((to, from, next) => {
|
|
126
|
-
const { authenticated, user, authBase, redirect, forcePasswordChange } = store.state.auth;
|
|
134
|
+
const { authenticated, user, authBase, redirect, forcePasswordChange, autoLogin } = store.state.auth;
|
|
127
135
|
|
|
128
136
|
const admin = to.path.includes("/admin");
|
|
129
137
|
|
|
@@ -133,7 +141,11 @@ export function configureRoutes(router) {
|
|
|
133
141
|
if (admin && !user?.admin) {
|
|
134
142
|
next({ name: redirect });
|
|
135
143
|
} else if (to.name === "login" || to.name === `${authBase}.login`) {
|
|
136
|
-
|
|
144
|
+
if(autoLogin) {
|
|
145
|
+
next({ name: `${authBase}.force-login` });
|
|
146
|
+
} else {
|
|
147
|
+
next({ name: redirect });
|
|
148
|
+
}
|
|
137
149
|
} else if (
|
|
138
150
|
!user?.email_verified_at &&
|
|
139
151
|
to.matched.some((d) => d.meta.guest) !== true
|
|
@@ -147,8 +159,14 @@ export function configureRoutes(router) {
|
|
|
147
159
|
next();
|
|
148
160
|
} else if (admin) {
|
|
149
161
|
next({ name: "login" });
|
|
162
|
+
} else if (to.path === "/callback") {
|
|
163
|
+
next({ name: `${authBase}.callback` });
|
|
150
164
|
} else {
|
|
151
|
-
|
|
165
|
+
if(autoLogin === true) {
|
|
166
|
+
next({ name: `${authBase}.force-login` });
|
|
167
|
+
} else {
|
|
168
|
+
next({ name: `${authBase}.login` });
|
|
169
|
+
}
|
|
152
170
|
}
|
|
153
171
|
}
|
|
154
172
|
});
|
|
@@ -9,7 +9,8 @@ const store = {
|
|
|
9
9
|
forcePasswordChange: false,
|
|
10
10
|
intended: null,
|
|
11
11
|
user: null,
|
|
12
|
-
redirect: process.env.HYDRATE_REDIRECT ?? 'index'
|
|
12
|
+
redirect: process.env.HYDRATE_REDIRECT ?? 'index',
|
|
13
|
+
autoLogin: process.env.HYDRATE_ADMIN === 'true' ? true: false,
|
|
13
14
|
}
|
|
14
15
|
},
|
|
15
16
|
|