Skip to content

Commit

Permalink
Fix logout behavior when token is invalid
Browse files Browse the repository at this point in the history
If the token is invalid then we should proceed as if the token had been successfully revoked.
  • Loading branch information
Piccirello committed Apr 28, 2021
1 parent e05a30e commit be53ffa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/cmd/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ func revokeToken(cmd *cobra.Command, args []string) {

_, err := http.RevokeAuthToken(localConfig.APIHost.Value, verifyTLS, token)
if !err.IsNil() {
utils.HandleError(err.Unwrap(), err.Message)
// ignore error if token was invalid
invalidToken := err.Code >= 400 && err.Code < 500
if invalidToken {
utils.LogDebug("Failed to revoke token")
utils.LogDebugError(err.Unwrap())
} else {
utils.HandleError(err.Unwrap(), err.Message)
}
}

if updateConfig {
Expand Down

0 comments on commit be53ffa

Please sign in to comment.