Этот коммит содержится в:
=Corey Hulen
2016-05-17 13:55:51 -07:00
родитель 123bfad69c
Коммит ac509b114d
3 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@@ -568,7 +568,7 @@ func GetSession(token string) *model.Session {
} else { } else {
session = sessionResult.Data.(*model.Session) session = sessionResult.Data.(*model.Session)
if session.IsExpired() { if session.IsExpired() || session.Token != token {
return nil return nil
} else { } else {
AddSessionToCache(session) AddSessionToCache(session)

Просмотреть файл

@@ -22,19 +22,19 @@ const (
type WebConn struct { type WebConn struct {
WebSocket *websocket.Conn WebSocket *websocket.Conn
Send chan *model.Message Send chan *model.Message
SessionId string SessionToken string
UserId string UserId string
hasPermissionsToChannel map[string]bool hasPermissionsToChannel map[string]bool
hasPermissionsToTeam map[string]bool hasPermissionsToTeam map[string]bool
} }
func NewWebConn(ws *websocket.Conn, userId string, sessionId string) *WebConn { func NewWebConn(ws *websocket.Conn, userId string, sessionToken string) *WebConn {
go func() { go func() {
achan := Srv.Store.User().UpdateUserAndSessionActivity(userId, sessionId, model.GetMillis()) achan := Srv.Store.User().UpdateUserAndSessionActivity(userId, sessionToken, model.GetMillis())
pchan := Srv.Store.User().UpdateLastPingAt(userId, model.GetMillis()) pchan := Srv.Store.User().UpdateLastPingAt(userId, model.GetMillis())
if result := <-achan; result.Err != nil { if result := <-achan; result.Err != nil {
l4g.Error(utils.T("api.web_conn.new_web_conn.last_activity.error"), userId, sessionId, result.Err) l4g.Error(utils.T("api.web_conn.new_web_conn.last_activity.error"), userId, sessionToken, result.Err)
} }
if result := <-pchan; result.Err != nil { if result := <-pchan; result.Err != nil {
@@ -46,7 +46,7 @@ func NewWebConn(ws *websocket.Conn, userId string, sessionId string) *WebConn {
Send: make(chan *model.Message, 64), Send: make(chan *model.Message, 64),
WebSocket: ws, WebSocket: ws,
UserId: userId, UserId: userId,
SessionId: sessionId, SessionToken: sessionToken,
hasPermissionsToChannel: make(map[string]bool), hasPermissionsToChannel: make(map[string]bool),
hasPermissionsToTeam: make(map[string]bool), hasPermissionsToTeam: make(map[string]bool),
} }
@@ -125,7 +125,7 @@ func (c *WebConn) InvalidateCacheForChannel(channelId string) {
func (c *WebConn) HasPermissionsToTeam(teamId string) bool { func (c *WebConn) HasPermissionsToTeam(teamId string) bool {
perm, ok := c.hasPermissionsToTeam[teamId] perm, ok := c.hasPermissionsToTeam[teamId]
if !ok { if !ok {
session := GetSession(c.SessionId) session := GetSession(c.SessionToken)
if session == nil { if session == nil {
perm = false perm = false
c.hasPermissionsToTeam[teamId] = perm c.hasPermissionsToTeam[teamId] = perm

Просмотреть файл

@@ -33,7 +33,7 @@ func connect(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
wc := NewWebConn(ws, c.Session.UserId, c.Session.Id) wc := NewWebConn(ws, c.Session.UserId, c.Session.Token)
hub.Register(wc) hub.Register(wc)
go wc.writePump() go wc.writePump()
wc.readPump() wc.readPump()