Add exchange api endpoint, fix jwt authtoken var type error

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2026-01-20 18:51:15 +08:00
parent 9b83ab565a
commit cd93491d98
8 changed files with 75 additions and 48 deletions

View File

@@ -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
}