Skip to content

Commit

Permalink
Merge pull request openshift#1754 from ggreer/auth-userid
Browse files Browse the repository at this point in the history
frontend: More defensive auth.userID() function.
  • Loading branch information
ggreer authored Sep 19, 2017
2 parents 380b428 + 9658886 commit fff7ebb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion frontend/public/module/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ const email = 'email';

export const authSvc = {
getToken: () => localStorage.getItem(bearerToken),
userID: () => loginStateItem(userID) && atob(loginStateItem(userID)),
userID: () => {
const id = loginStateItem(userID);
try {
return id && atob(id);
} catch (e) {
// eslint-disable-next-line no-console
console.error('error decoding userID', id, ':', e);
}
return id;
},
name: () => loginStateItem(name),
email: () => loginStateItem(email),

Expand Down

0 comments on commit fff7ebb

Please sign in to comment.