Skip to content

Commit db8f570

Browse files
committed
Closed labstack#1121
Signed-off-by: Vishal Rana <vr@labstack.com>
1 parent 09dcba1 commit db8f570

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

middleware/jwt.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type (
2323
SuccessHandler JWTSuccessHandler
2424

2525
// ErrorHandler defines a function which is executed for an invalid token.
26+
// It may be used to define a custom JWT error.
2627
ErrorHandler JWTErrorHandler
2728

2829
// Signing key to validate token.
@@ -61,7 +62,7 @@ type (
6162
JWTSuccessHandler func(echo.Context)
6263

6364
// JWTErrorHandler defines a function which is executed for an invalid token.
64-
JWTErrorHandler func(error, echo.Context, echo.HandlerFunc) error
65+
JWTErrorHandler func(error) error
6566

6667
jwtExtractor func(echo.Context) (string, error)
6768
)
@@ -158,7 +159,7 @@ func JWTWithConfig(config JWTConfig) echo.MiddlewareFunc {
158159
auth, err := extractor(c)
159160
if err != nil {
160161
if config.ErrorHandler != nil {
161-
return config.ErrorHandler(err, c, next)
162+
return config.ErrorHandler(err)
162163
}
163164
return err
164165
}
@@ -180,11 +181,11 @@ func JWTWithConfig(config JWTConfig) echo.MiddlewareFunc {
180181
return next(c)
181182
}
182183
if config.ErrorHandler != nil {
183-
return config.ErrorHandler(err, c, next)
184+
return config.ErrorHandler(err)
184185
}
185186
return &echo.HTTPError{
186187
Code: http.StatusUnauthorized,
187-
Message: "Invalid or expired jwt",
188+
Message: "invalid or expired jwt",
188189
Internal: err,
189190
}
190191
}

0 commit comments

Comments
 (0)