So I've created a small 2 page VUE with a login page and then routed over to a search page. On login the Python handles the LDAP check and creates the JWT and it looks like it exists in the cookies in the browser however i'm not sure how to handle it when back in "Vue" land.
In addition I though it wasn't great to keep this info in cookies in the browser....hmmmmm
const routes = [
{
path: '/',
name: 'home',
component: LoginEntry,
props:{test:'Service Center Search Portal'}
},
{
path: '/scsearch',
name: 'scsearch',
component: SearchView
},
Added Code
router.beforeEach(async (to, from, next) => {
console.log('runniing router');
console.log(to.name);
if (to.name === "scsearch") {
const response = await axios.get('/api/jwt/check');
console.log('juust did call');
console.log(response.status);
if ( response.status === 401 ) {
console.log('ressponse status 401');
return next({ name: "home" });
}
console.log('doing noothiing');
next();
}else{
next();
}
});
Added Code -2 (Working)
router.beforeEach(async (to, from, next) => {
console.log('runniing router');
console.log(to.name);
if (to.name === "scsearch") {
console.log('doing call');
const response = await axios.get('/api/jwt/check')
.then(function(value){
console.log(value);
next('/');
})
.catch(function(err){
console.log(err)
});
console.log('juust did call');
console.log(response);
console.log('doing noothiing');
next();
}else{
next();
}
});