Skip to content

A self-hosted media server and file management system

fix: login redirects to home rather than previous route

aminnausinb873cac22596
diff --git a/resources/js/router/index.ts b/resources/js/router/index.ts
index ff504b54..ac6b472b 100644
--- a/resources/js/router/index.ts
+++ b/resources/js/router/index.ts
@@ -212,19 +212,21 @@ router.beforeEach(async (to, from, next) => {
document.title = meta.title ?? toTitleCase(`${to.name?.toString()}`); // Update Page Title
}
- // Block logged in users if the route is guest-only
- if (to.meta.guestOnly) {
- return redirectGuest(next);
- }
-
// If going to 'login' and no redirect was specified, but the previous path had a value, navigate to login with a redirect to the previous page
if (to.name === 'login' && !to.query.redirect && from.fullPath !== '/') {
+ console.log(from.fullPath);
+
return next({
name: 'login',
query: { redirect: from.fullPath },
});
}
+ // Block logged in users if the route is guest-only
+ if (to.meta.guestOnly) {
+ return redirectGuest(next);
+ }
+
const isProtected = to.matched.some((r) => r.meta?.protected);
// Proceed to next route if unprotected