Fix token issue
This commit is contained in:
parent
cfb97485e3
commit
06bb34c0d7
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user