More of a general question more than anything. I am authenticating during login and storing the token jwt response in local storage and on each route change running checkLogin which checks the token is valid by hitting /token/validate. Im doing this asynchronously for unprotected pages to help with performance and requiring it for protected pages before proceeding. Im doing the same process for grabbing fresh user data for if user data has been updated in the mean time.
My question is do i need to validate each route change as theyve authenticated on login and each page has many protected REST endpoints that check against the token anyway so if any of those come back invalid i can force logout there instead. Trying to speed things up as on each route change its quite slow as it performs these lookups before getting any endpoint data for data on the page. Also for any endpoints that are quite data heavy is it worth prefetching those after login so when you visit the route it already has that data?
async handleRouteChange(newRoute, oldRoute) {
if (newRoute.path === '/edit-profile') {
await this.checkLogin();
} else {
this.checkLogin();
}
if(this.$store.state.user_data){
this.updateUserData();
}else{
await this.updateUserData();
}
},