Add exchange api endpoint, fix jwt authtoken var type error
Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"nixcn-cms/pkgs/authtoken"
|
||||
"nixcn-cms/utils"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func JWTAuth(required bool) gin.HandlerFunc {
|
||||
func JWTAuth() gin.HandlerFunc {
|
||||
|
||||
return func(c *gin.Context) {
|
||||
auth := c.GetHeader("Authorization")
|
||||
@@ -15,11 +16,7 @@ func JWTAuth(required bool) gin.HandlerFunc {
|
||||
authtoken := new(authtoken.Token)
|
||||
uid, err := authtoken.HeaderVerify(auth)
|
||||
if err != nil {
|
||||
utils.HttpAbort(c, 401, "", "unauthorized")
|
||||
return
|
||||
}
|
||||
|
||||
if required == true && uid == "" {
|
||||
fmt.Println(err)
|
||||
utils.HttpAbort(c, 401, "", "unauthorized")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user