Skip to content

Commit 8deff6f

Browse files
authored
Fix redirect on login (#85)
* Fix redirect on login * Fix typo
1 parent 6f8104a commit 8deff6f

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

templates/vue/application/src/auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let authenticated = true;
22
export default {
3-
athenticated() {
3+
authenticated() {
44
return authenticated;
55
},
66
logIn() {

templates/vue/application/src/components/header-toolbar.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ export default {
8989
onLogoutClick() {
9090
auth.logOut();
9191
this.$router.push({
92-
path: "/login-form"
92+
path: "/login-form",
93+
query: { redirect: this.$route.path }
9394
});
9495
}
9596
},

templates/vue/application/src/router.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ const router = new Router({
8080

8181
router.beforeEach((to, from, next) => {
8282

83-
if (to.name === "login-form" && auth.athenticated()) {
83+
if (to.name === "login-form" && auth.authenticated()) {
8484
next({ name: "home" });
8585
}
8686

8787
if (to.matched.some(record => record.meta.requiresAuth)) {
88-
if (!auth.athenticated()) {
88+
if (!auth.authenticated()) {
8989
next({
9090
name: "login-form",
9191
query: { redirect: to.fullPath }

templates/vue/application/src/views/login-form.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default {
7474
}
7575
7676
auth.logIn();
77-
this.$router.push("/home");
77+
this.$router.push(this.$route.query.redirect || "/home");
7878
7979
e.validationGroup.reset();
8080
}

0 commit comments

Comments
 (0)