summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-05-04 16:36:31 -0400
committerGitHub <noreply@github.com>2017-05-04 16:36:31 -0400
commitfe95276ba849bc7a520087369eea0aaff6c92358 (patch)
tree7eaa8cca5fdd2ab7d2839e474fe3e34f468fc7a3 /api
parent1838f6c25eb95a34f7fc5892e6896b3c3e2f3673 (diff)
downloadchat-fe95276ba849bc7a520087369eea0aaff6c92358.tar.gz
chat-fe95276ba849bc7a520087369eea0aaff6c92358.tar.bz2
chat-fe95276ba849bc7a520087369eea0aaff6c92358.zip
PLT-6492 Use new cookie to determine if user is logged in (#6317)
* Use new cookie to determine if user is logged in * Add temporary code for 3.9 to prevent forced re-login
Diffstat (limited to 'api')
-rw-r--r--api/context.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/api/context.go b/api/context.go
index 117fff708..f8953f547 100644
--- a/api/context.go
+++ b/api/context.go
@@ -185,6 +185,20 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}
+ // TEMPORARY CODE FOR 3.9, REMOVE FOR 3.10
+ if cookie, err := r.Cookie(model.SESSION_COOKIE_TOKEN); err == nil && c.Session.UserId != "" {
+ if _, err = r.Cookie(model.SESSION_COOKIE_USER); err != nil {
+ http.SetCookie(w, &http.Cookie{
+ Name: model.SESSION_COOKIE_USER,
+ Value: c.Session.UserId,
+ Path: "/",
+ MaxAge: cookie.MaxAge,
+ Expires: cookie.Expires,
+ Secure: cookie.Secure,
+ })
+ }
+ }
+
if h.isApi || h.isTeamIndependent {
c.setTeamURL(c.GetSiteURLHeader(), false)
c.Path = r.URL.Path
@@ -357,7 +371,15 @@ func (c *Context) RemoveSessionCookie(w http.ResponseWriter, r *http.Request) {
HttpOnly: true,
}
+ userCookie := &http.Cookie{
+ Name: model.SESSION_COOKIE_USER,
+ Value: "",
+ Path: "/",
+ MaxAge: -1,
+ }
+
http.SetCookie(w, cookie)
+ http.SetCookie(w, userCookie)
}
func (c *Context) SetInvalidParam(where string, name string) {