mirror of https://github.com/golang-jwt/jwt.git
Include expire delta in error message
This commit is contained in:
parent
a2c85815a7
commit
96fef82497
|
@ -5,6 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Parser struct {
|
type Parser struct {
|
||||||
|
@ -113,7 +114,8 @@ func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if vexp && now > exp {
|
if vexp && now > exp {
|
||||||
vErr.Inner = fmt.Errorf("token is expired")
|
delta := time.Unix(now, 0).Sub(time.Unix(exp, 0))
|
||||||
|
vErr.Inner = fmt.Errorf("token is expired by %v", delta)
|
||||||
vErr.Errors |= ValidationErrorExpired
|
vErr.Errors |= ValidationErrorExpired
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue