build: change jwt package to the new one

This commit is contained in:
hyperyuri 2021-11-11 15:26:42 -03:00
parent c3809c7cab
commit c4dc8a2c21
7 changed files with 114 additions and 31 deletions

View file

@ -2,6 +2,7 @@ package jwt
import (
"context"
"github.com/lestrrat-go/jwx/jwt"
"net/http"
"github.com/go-chi/jwtauth"
@ -40,7 +41,7 @@ func Authenticator(next http.Handler) http.Handler {
return
}
if !token.Valid {
if err := jwt.Validate(token); err != nil {
render.Render(w, r, ErrUnauthorized(ErrTokenExpired))
return
}
@ -69,7 +70,8 @@ func AuthenticateRefreshJWT(next http.Handler) http.Handler {
render.Render(w, r, ErrUnauthorized(ErrTokenUnauthorized))
return
}
if !token.Valid {
if err := jwt.Validate(token); err != nil {
render.Render(w, r, ErrUnauthorized(ErrTokenExpired))
return
}