Skip to content

Commit

Permalink
Add guards for invalid auth data
Browse files Browse the repository at this point in the history
  • Loading branch information
webprofusion-chrisc committed Nov 29, 2023
1 parent fa48b3d commit b65d8db
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/app/services/AppManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,17 @@ export class AppManager {

if (jwtString != null) {
let jwt = JSON.parse(jwtString);
if (jwt.Data != null && jwt.Data.access_token != null) {
if (jwt?.Data != null && jwt?.Data?.access_token != null) {
const decodedToken = this.jwtHelper.decodeToken(jwt.Data.access_token);
if (this.jwtHelper.isTokenExpired(jwt.Data.access_token)) {
localStorage.removeItem('authResponse');
} else {
this.api.authResponse = jwt;
this.logging.log('User has valid auth token in local storage', LogLevel.VERBOSE);
}
} else {
this.logging.log('User has invalid auth token in local storage', LogLevel.VERBOSE);
localStorage.removeItem('authResponse');
}
}
}
Expand Down

0 comments on commit b65d8db

Please sign in to comment.