Skip to content

Commit

Permalink
chore(auth): handle null return form token decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
pelord committed Dec 5, 2023
1 parent 4d6049a commit 047e074
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/auth/src/lib/shared/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export class AuthService {
}

get user(): User | null {
const { user = null } = this.decodeToken();
return user;
const decodedToken = this.decodeToken();
return decodedToken ? decodedToken.user ?? null : null;
}

constructor(
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/lib/shared/token.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class TokenService {
return localStorage.getItem(this.tokenKey);
}

decode(): IgoJwtPayload {
decode(): IgoJwtPayload | null {
const token = this.get();
if (!token) {
return;
Expand Down

0 comments on commit 047e074

Please sign in to comment.