@fishawack/lab-velocity 2.0.0-beta.61 → 2.0.0-beta.62
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.
|
@@ -185,6 +185,7 @@ export function routes(node) {
|
|
|
185
185
|
|
|
186
186
|
export function beforeEach(router, store) {
|
|
187
187
|
let initialLoad = true;
|
|
188
|
+
let redirectingToLogin = false;
|
|
188
189
|
|
|
189
190
|
// These routes must always be reachable regardless of auth/verification state.
|
|
190
191
|
// Without this, force_password_change or unverified state can trap the user with
|
|
@@ -258,9 +259,18 @@ export function beforeEach(router, store) {
|
|
|
258
259
|
|
|
259
260
|
// Unauthenticated: allow guest routes, otherwise redirect to login
|
|
260
261
|
if (isGuestRoute) {
|
|
262
|
+
// If the user navigated directly to login (not redirected here by this guard),
|
|
263
|
+
// clear any stale intended route so post-login lands on the default page.
|
|
264
|
+
if (to.name === "auth.login" && !redirectingToLogin) {
|
|
265
|
+
store.commit("setIntended", null);
|
|
266
|
+
}
|
|
267
|
+
redirectingToLogin = false;
|
|
261
268
|
return next();
|
|
262
269
|
}
|
|
263
270
|
|
|
271
|
+
// Store the intended destination before redirecting to login
|
|
272
|
+
store.commit("setIntended", to.fullPath);
|
|
273
|
+
redirectingToLogin = true;
|
|
264
274
|
return next({ name: "auth.login" });
|
|
265
275
|
});
|
|
266
276
|
}
|