You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to use the global before hook to check if I have a valid login session:
router.hooks({
before: function (done, params) {
if (global.sessionId === -1) {
router.navigate('/login/');
return;
}
done();
}
});
This creates an infinite loop, because even on the login page the sessionId is -1. Since I want my full website to be protected by this sessionId check, I would like to know how I can have this global hook for every route except for the /login/ route. Thanks in advance!
The text was updated successfully, but these errors were encountered:
With the latest 8.0.0 release you'll be able to do the following:
router.hooks({before: function(done,match){if(window.sessionId===-1&&match.url!=="login"){console.log("redirect to login");router.navigate("/login");return;}done();},});
The second argument of the hook is a Match object. You can use its url field to check what's the path that matched.
P.S.
as of today version 8.0.0 is not released officially. You could have the beta one by running yarn add navigo@beta.
I would like to use the global before hook to check if I have a valid login session:
This creates an infinite loop, because even on the login page the sessionId is -1. Since I want my full website to be protected by this sessionId check, I would like to know how I can have this global hook for every route except for the /login/ route. Thanks in advance!
The text was updated successfully, but these errors were encountered: