Fixing /logout command (#2908)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
204109b4b9
Коммит
d2f9fd52fe
@@ -33,6 +33,16 @@ func (me *LogoutProvider) GetCommand(c *Context) *model.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (me *LogoutProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse {
|
func (me *LogoutProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse {
|
||||||
|
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")}
|
||||||
|
|
||||||
return &model.CommandResponse{GotoLocation: c.GetTeamURL() + "/logout", 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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,17 +4,11 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/mattermost/platform/model"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLogoutTestCommand(t *testing.T) {
|
func TestLogoutTestCommand(t *testing.T) {
|
||||||
th := Setup().InitBasic()
|
th := Setup().InitBasic()
|
||||||
|
|
||||||
rs1 := th.BasicClient.Must(th.BasicClient.Command(th.BasicChannel.Id, "/logout", false)).Data.(*model.CommandResponse)
|
th.BasicClient.Must(th.BasicClient.Command(th.BasicChannel.Id, "/logout", false))
|
||||||
if !strings.HasSuffix(rs1.GotoLocation, "logout") {
|
|
||||||
t.Fatal("failed to logout")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -764,10 +764,7 @@ func Logout(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
c.LogAudit("")
|
c.LogAudit("")
|
||||||
c.RemoveSessionCookie(w, r)
|
c.RemoveSessionCookie(w, r)
|
||||||
if c.Session.Id != "" {
|
if c.Session.Id != "" {
|
||||||
if result := <-Srv.Store.Session().Remove(c.Session.Id); result.Err != nil {
|
RevokeSessionById(c, c.Session.Id)
|
||||||
c.Err = result.Err
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -387,6 +387,10 @@
|
|||||||
"id": "api.command_logout.success_message",
|
"id": "api.command_logout.success_message",
|
||||||
"translation": "Logging out..."
|
"translation": "Logging out..."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "api.command_logout.fail_message",
|
||||||
|
"translation": "Failed to log out"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "api.command_me.desc",
|
"id": "api.command_me.desc",
|
||||||
"translation": "Do an action"
|
"translation": "Do an action"
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user