Redirect user to visited page after login
This commit is contained in:
parent
062269f030
commit
9783bd802a
|
|
@ -114,12 +114,13 @@ function getCookieValue(a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirectIfLoginRequird(nameOfPage) {
|
function redirectIfLoginRequird(nameOfPage) {
|
||||||
return publicPages.indexOf(nameOfPage) === -1 && getCookieValue('loginStatus') !== 'True';
|
return publicPages.indexOf(nameOfPage) === -1 && getCookieValue('loginStatus') !== 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
if (redirectIfLoginRequird(to.name)) {
|
if (redirectIfLoginRequird(to.name)) {
|
||||||
next('/login');
|
const redirectUrl = `/login?redirect=${to.path}`;
|
||||||
|
next(redirectUrl);
|
||||||
} else {
|
} else {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,12 +90,14 @@ export default {
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
console.log('success', success)
|
|
||||||
if (success) {
|
if (success) {
|
||||||
|
const redirectUrl = that.$route.query.redirect ? that.$route.query.redirect : '/'
|
||||||
|
that.$router.push(redirectUrl);
|
||||||
} else {
|
} else {
|
||||||
that.loginError = 'Die E-Mail oder das Passwort ist falsch. Bitte versuchen Sie nochmals.';
|
that.loginError = 'Die E-Mail oder das Passwort ist falsch. Bitte versuchen Sie nochmals.';
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.warn(e);
|
||||||
that.loginError = 'Es ist ein Fehler aufgetreten. Bitte versuchen Sie nochmals.';
|
that.loginError = 'Es ist ein Fehler aufgetreten. Bitte versuchen Sie nochmals.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue