1
This commit is contained in:
parent
e25b0665f2
commit
a475fb982a
@ -2,26 +2,21 @@ package middleware
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
//. "main/global"
|
. "main/global"
|
||||||
//"net/http"
|
"net/http"
|
||||||
//"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Auth() gin.HandlerFunc {
|
func Auth() gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
/*
|
|
||||||
token := c.Request.Header.Get("Authorization")
|
token := c.Request.Header.Get("Authorization")
|
||||||
strArr := strings.Split(token, "|")
|
s := GetSessionMgr().GetSessionByToken(token)
|
||||||
authToken := GetApp().GetSessionAccountId(strArr[0])
|
if s == nil {
|
||||||
if token == "" || token != authToken {
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 50014,
|
"code": 50014,
|
||||||
"message": "未登录或非法访问",
|
"message": "未登录或非法访问",
|
||||||
})
|
})
|
||||||
response.FailWithDetailed(gin.H{"reload": true}, "未登录或非法访问", c)
|
|
||||||
c.Abort()
|
c.Abort()
|
||||||
return
|
return
|
||||||
}*/
|
}
|
||||||
c.Next()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package session
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"f5"
|
"f5"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type session struct {
|
type session struct {
|
||||||
@ -25,7 +26,7 @@ func (this *session) GetLoginTime() int32 {
|
|||||||
|
|
||||||
func newSession(accountAddress string, token string) *session {
|
func newSession(accountAddress string, token string) *session {
|
||||||
p := new(session)
|
p := new(session)
|
||||||
p.accountAddress = accountAddress
|
p.accountAddress = strings.ToLower(accountAddress)
|
||||||
p.token = token
|
p.token = token
|
||||||
p.loginTime = int32(f5.GetApp().GetRealSeconds())
|
p.loginTime = int32(f5.GetApp().GetRealSeconds())
|
||||||
return p
|
return p
|
||||||
|
@ -48,6 +48,8 @@ func (this *sessionMgr) AddSession(accountAddress string, token string) common.S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
s := newSession(accountAddress, token)
|
s := newSession(accountAddress, token)
|
||||||
|
this.addressHash.Store(accountAddress, s)
|
||||||
|
this.sessionHash.Store(token, s)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user