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) {
|
||||
return publicPages.indexOf(nameOfPage) === -1 && getCookieValue('loginStatus') !== 'True';
|
||||
return publicPages.indexOf(nameOfPage) === -1 && getCookieValue('loginStatus') !== 'true';
|
||||
}
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (redirectIfLoginRequird(to.name)) {
|
||||
next('/login');
|
||||
const redirectUrl = `/login?redirect=${to.path}`;
|
||||
next(redirectUrl);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,12 +90,14 @@ export default {
|
|||
}
|
||||
) {
|
||||
try {
|
||||
console.log('success', success)
|
||||
if (success) {
|
||||
const redirectUrl = that.$route.query.redirect ? that.$route.query.redirect : '/'
|
||||
that.$router.push(redirectUrl);
|
||||
} else {
|
||||
that.loginError = 'Die E-Mail oder das Passwort ist falsch. Bitte versuchen Sie nochmals.';
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
that.loginError = 'Es ist ein Fehler aufgetreten. Bitte versuchen Sie nochmals.';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue