Handling redirects to login and user dashboard depending on token validation