documentation fix

This commit is contained in:
Dave Grijalva 2014-03-07 14:46:27 -08:00
parent 1a8b763fae
commit aa7f010b16
1 changed files with 4 additions and 2 deletions

6
jwt.go
View File

@ -144,7 +144,7 @@ func Parse(tokenString string, keyFunc Keyfunc) (*Token, error) {
vErr.SignatureInvalid = true vErr.SignatureInvalid = true
} }
if vErr.Valid() { if vErr.valid() {
token.Valid = true token.Valid = true
return token, nil return token, nil
} }
@ -156,6 +156,7 @@ func Parse(tokenString string, keyFunc Keyfunc) (*Token, error) {
} }
} }
// The error from Parse if token is not valid
type ValidationError struct { type ValidationError struct {
err string err string
Malformed bool //Token is malformed Malformed bool //Token is malformed
@ -165,6 +166,7 @@ type ValidationError struct {
NotValidYet bool // NBF validation failed NotValidYet bool // NBF validation failed
} }
// Validation error is an error type
func (e *ValidationError) Error() string { func (e *ValidationError) Error() string {
if e.err == "" { if e.err == "" {
return "Token is invalid" return "Token is invalid"
@ -173,7 +175,7 @@ func (e *ValidationError) Error() string {
} }
// No errors // No errors
func (e *ValidationError) Valid() bool { func (e *ValidationError) valid() bool {
if e.Malformed || e.Unverifiable || e.SignatureInvalid || e.Expired || e.NotValidYet { if e.Malformed || e.Unverifiable || e.SignatureInvalid || e.Expired || e.NotValidYet {
return false return false
} }