This commit is contained in:
aozhiwei 2024-07-13 18:32:00 +08:00
parent e25b0665f2
commit a475fb982a
3 changed files with 9 additions and 11 deletions

View File

@ -2,26 +2,21 @@ package middleware
import (
"github.com/gin-gonic/gin"
//. "main/global"
//"net/http"
//"strings"
. "main/global"
"net/http"
)
func Auth() gin.HandlerFunc {
return func(c *gin.Context) {
/*
token := c.Request.Header.Get("Authorization")
strArr := strings.Split(token, "|")
authToken := GetApp().GetSessionAccountId(strArr[0])
if token == "" || token != authToken {
s := GetSessionMgr().GetSessionByToken(token)
if s == nil {
c.JSON(http.StatusOK, gin.H{
"code": 50014,
"message": "未登录或非法访问",
})
response.FailWithDetailed(gin.H{"reload": true}, "未登录或非法访问", c)
c.Abort()
return
}*/
c.Next()
}
}
}

View File

@ -2,6 +2,7 @@ package session
import (
"f5"
"strings"
)
type session struct {
@ -25,7 +26,7 @@ func (this *session) GetLoginTime() int32 {
func newSession(accountAddress string, token string) *session {
p := new(session)
p.accountAddress = accountAddress
p.accountAddress = strings.ToLower(accountAddress)
p.token = token
p.loginTime = int32(f5.GetApp().GetRealSeconds())
return p

View File

@ -48,6 +48,8 @@ func (this *sessionMgr) AddSession(accountAddress string, token string) common.S
}
}
s := newSession(accountAddress, token)
this.addressHash.Store(accountAddress, s)
this.sessionHash.Store(token, s)
return s
}