Merge pull request #24 from go-chi/err_notoken

Add ErrNoTokenFound verify error
This commit is contained in:
Vojtech Vitek 2018-01-17 19:29:29 -05:00 committed by GitHub
commit 5d94d7c263
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,6 +19,7 @@ var (
var (
ErrUnauthorized = errors.New("jwtauth: token is unauthorized")
ErrExpired = errors.New("jwtauth: token is expired")
ErrNoTokenFound = errors.New("jwtauth: no token found")
)
type JWTAuth struct {
@ -97,6 +98,9 @@ func VerifyRequest(ja *JWTAuth, r *http.Request, findTokenFns ...func(r *http.Re
break
}
}
if tokenStr == "" {
return nil, ErrNoTokenFound
}
// TODO: what other kinds of validations should we do / error messages?