1
This commit is contained in:
parent
e25b0665f2
commit
a475fb982a
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user