Add ErrNoTokenFound verify error

This commit is contained in:
Vojtech Vitek 2018-01-17 19:23:35 -05:00
parent 47cdb657f2
commit ca8a698a9c

View file

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