summaryrefslogtreecommitdiffstats
path: root/app/web_conn.go
diff options
context:
space:
mode:
Diffstat (limited to 'app/web_conn.go')
-rw-r--r--app/web_conn.go28
1 files changed, 19 insertions, 9 deletions
diff --git a/app/web_conn.go b/app/web_conn.go
index 5205ac2ee..012236513 100644
--- a/app/web_conn.go
+++ b/app/web_conn.go
@@ -29,6 +29,7 @@ type WebConn struct {
Send chan model.WebSocketMessage
SessionToken string
SessionExpiresAt int64
+ Session *model.Session
UserId string
T goi18n.TranslateFunc
Locale string
@@ -148,6 +149,7 @@ func (webCon *WebConn) InvalidateCache() {
webCon.AllChannelMembers = nil
webCon.LastAllChannelMembersTime = 0
webCon.SessionExpiresAt = 0
+ webCon.Session = nil
}
func (webCon *WebConn) IsAuthenticated() bool {
@@ -162,11 +164,13 @@ func (webCon *WebConn) IsAuthenticated() bool {
l4g.Error(utils.T("api.websocket.invalid_session.error"), err.Error())
webCon.SessionToken = ""
webCon.SessionExpiresAt = 0
+ webCon.Session = nil
return false
}
webCon.SessionToken = session.Token
webCon.SessionExpiresAt = session.ExpiresAt
+ webCon.Session = session
}
return true
@@ -231,17 +235,23 @@ func (webCon *WebConn) ShouldSendEvent(msg *model.WebSocketEvent) bool {
}
func (webCon *WebConn) IsMemberOfTeam(teamId string) bool {
- session, err := GetSession(webCon.SessionToken)
- if err != nil {
- l4g.Error(utils.T("api.websocket.invalid_session.error"), err.Error())
- return false
- } else {
- member := session.GetTeamByTeamId(teamId)
- if member != nil {
- return true
- } else {
+ if webCon.Session == nil {
+ session, err := GetSession(webCon.SessionToken)
+ if err != nil {
+ l4g.Error(utils.T("api.websocket.invalid_session.error"), err.Error())
return false
+ } else {
+ webCon.Session = session
}
+
+ }
+
+ member := webCon.Session.GetTeamByTeamId(teamId)
+
+ if member != nil {
+ return true
+ } else {
+ return false
}
}