Skip to content

Commit

Permalink
Bugfix/user panic (#3648)
Browse files Browse the repository at this point in the history
Perform a nil check on tokens return from jwt.ParseWithClaims

Signed-off-by: Nikki Attea <[email protected]>
  • Loading branch information
Nikki Attea authored Mar 25, 2020
1 parent a109861 commit 821ed3e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cli/commands/helpers/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ func GetCurrentUsername(cfg config.Config) string {

accessToken := tokens.Access
token, _ := jwt.ParseWithClaims(accessToken, &corev2.Claims{}, nil)
if token == nil {
return ""
}
claims := token.Claims.(*corev2.Claims)
return claims.StandardClaims.Subject
}

0 comments on commit 821ed3e

Please sign in to comment.