mirror of https://github.com/golang-jwt/jwt.git
Adjusting the error checking example (#270)
This PR adjusts the error checking example so that a check for an invalid signature is also included. See discussion in #143
This commit is contained in:
parent
b357385d3e
commit
1c4047f488
|
@ -164,6 +164,9 @@ func ExampleParse_errorChecking() {
|
||||||
fmt.Println("You look nice today")
|
fmt.Println("You look nice today")
|
||||||
} else if errors.Is(err, jwt.ErrTokenMalformed) {
|
} else if errors.Is(err, jwt.ErrTokenMalformed) {
|
||||||
fmt.Println("That's not even a token")
|
fmt.Println("That's not even a token")
|
||||||
|
} else if errors.Is(err, jwt.ErrTokenSignatureInvalid) {
|
||||||
|
// Invalid signature
|
||||||
|
fmt.Println("Invalid signature")
|
||||||
} else if errors.Is(err, jwt.ErrTokenExpired) || errors.Is(err, jwt.ErrTokenNotValidYet) {
|
} else if errors.Is(err, jwt.ErrTokenExpired) || errors.Is(err, jwt.ErrTokenNotValidYet) {
|
||||||
// Token is either expired or not active yet
|
// Token is either expired or not active yet
|
||||||
fmt.Println("Timing is everything")
|
fmt.Println("Timing is everything")
|
||||||
|
|
Loading…
Reference in New Issue