I have this code for a token , generated with JWT
, then I return it to the application if the user accessed it correctly.
var token = $localStorage.token;
var base64Url = token.split('.')[1];
var base64 = base64Url.replace('-', '+').replace('_', '/');
var tokenObj = JSON.parse(atob(base64));
then validate that the token has the following claim webUserId
if(tokenObj.webUserId){...}
If I replace the value of the token in the localstorage , I expect an error to appear because it is not well-built, but at this point I get an exception:
var tokenObj = JSON.parse(atob(base64));
I get a $exceptionHandler
in Angular in the debug console.
How can I control this error so that the angle exception does not come out?