@@ -1,7 +1,7 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"nixcn-cms/exception"
|
||||
"nixcn-cms/pkgs/authtoken"
|
||||
"nixcn-cms/utils"
|
||||
|
||||
@@ -16,8 +16,15 @@ func JWTAuth() gin.HandlerFunc {
|
||||
authtoken := new(authtoken.Token)
|
||||
uid, err := authtoken.HeaderVerify(auth)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
utils.HttpAbort(c, 401, "", "unauthorized")
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusServer).
|
||||
SetService(exception.MiddlewareJwtService).
|
||||
SetEndpoint(exception.MiddlewareEndpoint).
|
||||
SetType(exception.ErrorTypeSpecific).
|
||||
SetOriginal(exception.CommonErrorUnauthorized).
|
||||
Build()
|
||||
|
||||
utils.HttpAbort(c, 401, errorCode)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user