mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
feat: improve api token verification compatibility
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/crawlab-team/crawlab/core/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func AuthorizationMiddleware() gin.HandlerFunc {
|
||||
@@ -28,6 +29,9 @@ func AuthorizationMiddleware() gin.HandlerFunc {
|
||||
|
||||
// token string
|
||||
tokenStr := c.GetHeader("Authorization")
|
||||
if strings.HasPrefix(tokenStr, "Bearer ") {
|
||||
tokenStr = strings.Replace(tokenStr, "Bearer ", "", 1)
|
||||
}
|
||||
|
||||
// validate token
|
||||
u, err := userSvc.CheckToken(tokenStr)
|
||||
|
||||
Reference in New Issue
Block a user