summaryrefslogtreecommitdiffstats
path: root/api/command_logout.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-05-06 12:08:49 -0400
committerJoram Wilander <jwawilander@gmail.com>2016-05-06 12:08:49 -0400
commitd2f9fd52fe8b0da6f23775f242660329fcef6421 (patch)
treee9a0b055d2bda65613f346fce256be9642ea1356 /api/command_logout.go
parent204109b4b9a62479181396523d080e43fb5d48db (diff)
downloadchat-d2f9fd52fe8b0da6f23775f242660329fcef6421.tar.gz
chat-d2f9fd52fe8b0da6f23775f242660329fcef6421.tar.bz2
chat-d2f9fd52fe8b0da6f23775f242660329fcef6421.zip
Fixing /logout command (#2908)
Diffstat (limited to 'api/command_logout.go')
-rw-r--r--api/command_logout.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/api/command_logout.go b/api/command_logout.go
index 912093162..9fff4e2d5 100644
--- a/api/command_logout.go
+++ b/api/command_logout.go
@@ -33,6 +33,16 @@ func (me *LogoutProvider) GetCommand(c *Context) *model.Command {
}
func (me *LogoutProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse {
-
- return &model.CommandResponse{GotoLocation: c.GetTeamURL() + "/logout", ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: c.T("api.command_logout.success_message")}
+ FAIL := &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: c.T("api.command_logout.fail_message")}
+ SUCCESS := &model.CommandResponse{GotoLocation: "/", ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: c.T("api.command_logout.success_message")}
+
+ // We can't actually remove the user's cookie from here so we just dump their session and let the browser figure it out
+ if c.Session.Id != "" {
+ RevokeSessionById(c, c.Session.Id)
+ if c.Err != nil {
+ return FAIL
+ }
+ return SUCCESS
+ }
+ return FAIL
}