From 06bb34c0d73254f455d2c0e7baa0de2a94dd20ff Mon Sep 17 00:00:00 2001 From: qowevisa Date: Thu, 31 Oct 2024 10:07:36 +0200 Subject: [PATCH] Fix token issue --- middleware/auth.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/middleware/auth.go b/middleware/auth.go index fbfd491..3c502ad 100644 --- a/middleware/auth.go +++ b/middleware/auth.go @@ -1,6 +1,8 @@ package middleware import ( + "strings" + "git.qowevisa.me/Qowevisa/gonuts/tokens" "git.qowevisa.me/Qowevisa/gonuts/types" "github.com/gin-gonic/gin" @@ -17,6 +19,10 @@ func AuthMiddleware() gin.HandlerFunc { } token := authHeader + if strings.Index(token, "Bearer ") == 0 { + token = strings.Split(token, " ")[1] + } + if !tokens.AmIAllowed(token) { c.JSON(401, types.ErrorResponse{Message: "Token is invalid"}) c.Abort()