summaryrefslogtreecommitdiffstats
path: root/api/user.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-10-20 04:37:51 -0700
committer=Corey Hulen <corey@hulen.com>2015-10-20 04:37:51 -0700
commitfa3a0df2b63d3f1bbbad44bf20afa48fed42aa06 (patch)
tree7ed37f554aae729a6fad579bc1a82e988de45971 /api/user.go
parent36658c13a4c7ebdfff22b8570e0db52bfa4de000 (diff)
downloadchat-fa3a0df2b63d3f1bbbad44bf20afa48fed42aa06.tar.gz
chat-fa3a0df2b63d3f1bbbad44bf20afa48fed42aa06.tar.bz2
chat-fa3a0df2b63d3f1bbbad44bf20afa48fed42aa06.zip
Adding multi-session cookie
Diffstat (limited to 'api/user.go')
-rw-r--r--api/user.go17
1 files changed, 6 insertions, 11 deletions
diff --git a/api/user.go b/api/user.go
index ac33e81a1..1216dd30d 100644
--- a/api/user.go
+++ b/api/user.go
@@ -428,21 +428,14 @@ func Login(c *Context, w http.ResponseWriter, r *http.Request, user *model.User,
}
w.Header().Set(model.HEADER_TOKEN, session.Token)
- sessionCookie := &http.Cookie{
- Name: model.SESSION_TOKEN,
- Value: session.Token,
- Path: "/",
- MaxAge: maxAge,
- HttpOnly: true,
- }
-
- http.SetCookie(w, sessionCookie)
multiToken := ""
- if originalMultiSessionCookie, err := r.Cookie(model.MULTI_SESSION_TOKEN); err == nil {
+ if originalMultiSessionCookie, err := r.Cookie(model.SESSION_COOKIE_TOKEN); err == nil {
multiToken = originalMultiSessionCookie.Value
}
+ fmt.Println("original: " + multiToken)
+
// Attempt to clean all the old tokens or duplicate tokens
if len(multiToken) > 0 {
tokens := strings.Split(multiToken, " ")
@@ -463,8 +456,10 @@ func Login(c *Context, w http.ResponseWriter, r *http.Request, user *model.User,
multiToken = strings.TrimSpace(session.Token + " " + multiToken)
+ fmt.Println("new: " + multiToken)
+
multiSessionCookie := &http.Cookie{
- Name: model.MULTI_SESSION_TOKEN,
+ Name: model.SESSION_COOKIE_TOKEN,
Value: multiToken,
Path: "/",
MaxAge: maxAge,