✨ add session
This commit is contained in:
@@ -43,6 +43,17 @@ func JWTAuthMiddleware() gin.HandlerFunc {
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
uid := c.GetHeader("X-UID")
|
||||
if uid == "" {
|
||||
result.FailWithCodeAndMessage(403, ginI18n.MustGetMessage(c, "AuthVerifyExpired"), c)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
if *parseToken.UserID != uid {
|
||||
result.FailWithCodeAndMessage(403, ginI18n.MustGetMessage(c, "AuthVerifyExpired"), c)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
token := redis.Get(constant.UserLoginTokenRedisKey + *parseToken.UserID).Val()
|
||||
if token == "" {
|
||||
result.FailWithCodeAndMessage(403, ginI18n.MustGetMessage(c, "AuthVerifyExpired"), c)
|
||||
|
@@ -6,9 +6,8 @@ import (
|
||||
|
||||
func SecurityHeaders() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
//url := strings.TrimPrefix(global.CONFIG.System.Web, "https://")
|
||||
//requestHost := c.Request.Host
|
||||
//if requestHost != url {
|
||||
//if requestHost != global.CONFIG.System.Web {
|
||||
// result.FailWithMessage(ginI18n.MustGetMessage(c, "IllegalRequests"), c)
|
||||
// c.Abort()
|
||||
// return
|
||||
|
Reference in New Issue
Block a user