Fix token issue
This commit is contained in:
parent
cfb97485e3
commit
06bb34c0d7
|
@ -1,6 +1,8 @@
|
||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"git.qowevisa.me/Qowevisa/gonuts/tokens"
|
"git.qowevisa.me/Qowevisa/gonuts/tokens"
|
||||||
"git.qowevisa.me/Qowevisa/gonuts/types"
|
"git.qowevisa.me/Qowevisa/gonuts/types"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
@ -17,6 +19,10 @@ func AuthMiddleware() gin.HandlerFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
token := authHeader
|
token := authHeader
|
||||||
|
if strings.Index(token, "Bearer ") == 0 {
|
||||||
|
token = strings.Split(token, " ")[1]
|
||||||
|
}
|
||||||
|
|
||||||
if !tokens.AmIAllowed(token) {
|
if !tokens.AmIAllowed(token) {
|
||||||
c.JSON(401, types.ErrorResponse{Message: "Token is invalid"})
|
c.JSON(401, types.ErrorResponse{Message: "Token is invalid"})
|
||||||
c.Abort()
|
c.Abort()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user