diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/context.go | 10 | ||||
-rw-r--r-- | api/oauth.go | 2 | ||||
-rw-r--r-- | api/post.go | 2 | ||||
-rw-r--r-- | api/team.go | 4 | ||||
-rw-r--r-- | api/user.go | 24 | ||||
-rw-r--r-- | api/user_test.go | 2 |
6 files changed, 22 insertions, 22 deletions
diff --git a/api/context.go b/api/context.go index 13f0f2c42..2dcf51e10 100644 --- a/api/context.go +++ b/api/context.go @@ -162,7 +162,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } if len(token) != 0 { - session := GetSession(token) + session := GetSession(c.T, token) if session == nil || session.IsExpired() { c.RemoveSessionCookie(w, r) @@ -515,14 +515,14 @@ func Handle404(w http.ResponseWriter, r *http.Request) { RenderWebError(err, w, r) } -func GetSession(token string) *model.Session { +func GetSession(T goi18n.TranslateFunc, token string) *model.Session { var session *model.Session if ts, ok := sessionCache.Get(token); ok { session = ts.(*model.Session) } if session == nil { - if sessionResult := <-Srv.Store.Session().Get(token); sessionResult.Err != nil { + if sessionResult := <-Srv.Store.Session().Get(T, token); sessionResult.Err != nil { l4g.Error("Invalid session token=" + token + ", err=" + sessionResult.Err.DetailedError) } else { session = sessionResult.Data.(*model.Session) @@ -551,9 +551,9 @@ func GetMultiSessionCookieTokens(r *http.Request) []string { return []string{} } -func FindMultiSessionForTeamId(r *http.Request, teamId string) (int64, *model.Session) { +func FindMultiSessionForTeamId(T goi18n.TranslateFunc, r *http.Request, teamId string) (int64, *model.Session) { for index, token := range GetMultiSessionCookieTokens(r) { - s := GetSession(token) + s := GetSession(T, token) if s != nil && !s.IsExpired() && s.TeamId == teamId { return int64(index), s } diff --git a/api/oauth.go b/api/oauth.go index 64848d0ce..47bedc20a 100644 --- a/api/oauth.go +++ b/api/oauth.go @@ -129,7 +129,7 @@ func allowOAuth(c *Context, w http.ResponseWriter, r *http.Request) { func RevokeAccessToken(T goi18n.TranslateFunc, token string) *model.AppError { - schan := Srv.Store.Session().Remove(token) + schan := Srv.Store.Session().Remove(T, token) sessionCache.Remove(token) var accessData *model.AccessData diff --git a/api/post.go b/api/post.go index c54bd59b3..f78dd0dcd 100644 --- a/api/post.go +++ b/api/post.go @@ -626,7 +626,7 @@ func sendNotificationsAndForget(c *Context, post *model.Post, team *model.Team, } if *utils.Cfg.EmailSettings.SendPushNotifications { - sessionChan := Srv.Store.Session().GetSessions(id) + sessionChan := Srv.Store.Session().GetSessions(c.T, id) if result := <-sessionChan; result.Err != nil { l4g.Error("Failed to retrieve sessions in notifications id=%v, err=%v", id, result.Err) } else { diff --git a/api/team.go b/api/team.go index eb328ce7b..0d0f440d8 100644 --- a/api/team.go +++ b/api/team.go @@ -331,7 +331,7 @@ func revokeAllSessions(c *Context, w http.ResponseWriter, r *http.Request) { props := model.MapFromJson(r.Body) id := props["id"] - if result := <-Srv.Store.Session().Get(id); result.Err != nil { + if result := <-Srv.Store.Session().Get(c.T, id); result.Err != nil { c.Err = result.Err return } else { @@ -344,7 +344,7 @@ func revokeAllSessions(c *Context, w http.ResponseWriter, r *http.Request) { } else { sessionCache.Remove(session.Token) - if result := <-Srv.Store.Session().Remove(session.Id); result.Err != nil { + if result := <-Srv.Store.Session().Remove(c.T, session.Id); result.Err != nil { c.Err = result.Err return } else { diff --git a/api/user.go b/api/user.go index 142fe10b8..d529dfee8 100644 --- a/api/user.go +++ b/api/user.go @@ -516,7 +516,7 @@ func Login(c *Context, w http.ResponseWriter, r *http.Request, user *model.User, maxAge = *utils.Cfg.ServiceSettings.SessionLengthMobileInDays * 60 * 60 * 24 // A special case where we logout of all other sessions with the same Id - if result := <-Srv.Store.Session().GetSessions(user.Id); result.Err != nil { + if result := <-Srv.Store.Session().GetSessions(c.T, user.Id); result.Err != nil { c.Err = result.Err c.Err.StatusCode = http.StatusForbidden return @@ -563,7 +563,7 @@ func Login(c *Context, w http.ResponseWriter, r *http.Request, user *model.User, session.AddProp(model.SESSION_PROP_OS, os) session.AddProp(model.SESSION_PROP_BROWSER, fmt.Sprintf("%v/%v", bname, bversion)) - if result := <-Srv.Store.Session().Save(session); result.Err != nil { + if result := <-Srv.Store.Session().Save(c.T, session); result.Err != nil { c.Err = result.Err c.Err.StatusCode = http.StatusForbidden return @@ -579,7 +579,7 @@ func Login(c *Context, w http.ResponseWriter, r *http.Request, user *model.User, seen := make(map[string]string) seen[session.TeamId] = session.TeamId for _, token := range tokens { - s := GetSession(token) + s := GetSession(c.T, token) if s != nil && !s.IsExpired() && seen[s.TeamId] == "" { multiToken += " " + token seen[s.TeamId] = s.TeamId @@ -706,7 +706,7 @@ func revokeSession(c *Context, w http.ResponseWriter, r *http.Request) { } func RevokeSessionById(c *Context, sessionId string) { - if result := <-Srv.Store.Session().Get(sessionId); result.Err != nil { + if result := <-Srv.Store.Session().Get(c.T, sessionId); result.Err != nil { c.Err = result.Err } else { session := result.Data.(*model.Session) @@ -717,7 +717,7 @@ func RevokeSessionById(c *Context, sessionId string) { } else { sessionCache.Remove(session.Token) - if result := <-Srv.Store.Session().Remove(session.Id); result.Err != nil { + if result := <-Srv.Store.Session().Remove(c.T, session.Id); result.Err != nil { c.Err = result.Err } } @@ -725,7 +725,7 @@ func RevokeSessionById(c *Context, sessionId string) { } func RevokeAllSession(c *Context, userId string) { - if result := <-Srv.Store.Session().GetSessions(userId); result.Err != nil { + if result := <-Srv.Store.Session().GetSessions(c.T, userId); result.Err != nil { c.Err = result.Err return } else { @@ -737,7 +737,7 @@ func RevokeAllSession(c *Context, userId string) { RevokeAccessToken(c.T, session.Token) } else { sessionCache.Remove(session.Token) - if result := <-Srv.Store.Session().Remove(session.Id); result.Err != nil { + if result := <-Srv.Store.Session().Remove(c.T, session.Id); result.Err != nil { c.Err = result.Err return } @@ -755,7 +755,7 @@ func getSessions(c *Context, w http.ResponseWriter, r *http.Request) { return } - if result := <-Srv.Store.Session().GetSessions(id); result.Err != nil { + if result := <-Srv.Store.Session().GetSessions(c.T, id); result.Err != nil { c.Err = result.Err return } else { @@ -781,7 +781,7 @@ func logout(c *Context, w http.ResponseWriter, r *http.Request) { func Logout(c *Context, w http.ResponseWriter, r *http.Request) { c.LogAudit("") c.RemoveSessionCookie(w, r) - if result := <-Srv.Store.Session().Remove(c.Session.Id); result.Err != nil { + if result := <-Srv.Store.Session().Remove(c.T, c.Session.Id); result.Err != nil { c.Err = result.Err return } @@ -1280,8 +1280,8 @@ func updateRoles(c *Context, w http.ResponseWriter, r *http.Request) { return } - uchan := Srv.Store.Session().UpdateRoles(user.Id, new_roles) - gchan := Srv.Store.Session().GetSessions(user.Id) + uchan := Srv.Store.Session().UpdateRoles(c.T, user.Id, new_roles) + gchan := Srv.Store.Session().GetSessions(c.T, user.Id) if result := <-uchan; result.Err != nil { // soft error since the user roles were still updated @@ -1436,7 +1436,7 @@ func PermanentDeleteUser(c *Context, user *model.User) *model.AppError { UpdateActive(c, user, false) - if result := <-Srv.Store.Session().PermanentDeleteSessionsByUser(user.Id); result.Err != nil { + if result := <-Srv.Store.Session().PermanentDeleteSessionsByUser(c.T, user.Id); result.Err != nil { return result.Err } diff --git a/api/user_test.go b/api/user_test.go index 9a172805a..1728cdcde 100644 --- a/api/user_test.go +++ b/api/user_test.go @@ -186,7 +186,7 @@ func TestLoginWithDeviceId(t *testing.T) { t.Fatal(err) } - if sresult := <-Srv.Store.Session().Get(sessions[0].Id); sresult.Err == nil { + if sresult := <-Srv.Store.Session().Get(utils.T, sessions[0].Id); sresult.Err == nil { t.Fatal("session should have been removed") } } |