Hello
I want to check Auth and redirect to a login page beforeEnter
.
It works when accessing the website from the homepage, but if I go to the page “users”, reload, it does not work anymore.
Problem is, that jquery is loaded in index and is not loaded, if reloading users-page.
-
How to solve this?
-
Is there a way to checkAuth with
beforeEnter
for my homepage “/” and redirect to login?beforeEnter
on my homepage has no effect.
Thank you!
function checkAuth({ to, from, resolve, reject }) {
const router = this;
var session;
$.ajaxSetup({cache: false})
$.get('get_session.php', function (data) {
session = JSON.parse(data);
if (session.member_permission == null || session.member_permission < 2) {
reject();
router.navigate('/login/');
return;
} else {
resolve();
}
});
}