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:
Christian Banse 2023-03-24 23:11:38 +01:00 committed by GitHub
parent b357385d3e
commit 1c4047f488
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -164,6 +164,9 @@ func ExampleParse_errorChecking() {
fmt.Println("You look nice today")
} else if errors.Is(err, jwt.ErrTokenMalformed) {
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) {
// Token is either expired or not active yet
fmt.Println("Timing is everything")