2019-11-29 12:59:40 +01:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
|
// See LICENSE.txt for license information.
|
2016-01-09 08:54:07 -06:00
|
|
|
|
2020-08-12 18:29:58 +02:00
|
|
|
package slashcommands
|
2016-01-09 08:54:07 -06:00
|
|
|
|
|
|
|
|
import (
|
2020-08-12 18:29:58 +02:00
|
|
|
"github.com/mattermost/mattermost-server/v5/app"
|
2021-05-11 13:00:44 +03:00
|
|
|
"github.com/mattermost/mattermost-server/v5/app/request"
|
2019-11-28 14:39:38 +01:00
|
|
|
"github.com/mattermost/mattermost-server/v5/model"
|
2021-02-26 08:12:49 +01:00
|
|
|
"github.com/mattermost/mattermost-server/v5/shared/i18n"
|
2016-01-09 08:54:07 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type LogoutProvider struct {
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-01 18:52:43 -08:00
|
|
|
const (
|
2021-01-04 11:32:29 +05:30
|
|
|
CmdLogout = "logout"
|
2016-02-01 18:52:43 -08:00
|
|
|
)
|
|
|
|
|
|
2016-01-09 08:54:07 -06:00
|
|
|
func init() {
|
2020-08-12 18:29:58 +02:00
|
|
|
app.RegisterCommandProvider(&LogoutProvider{})
|
2016-01-09 08:54:07 -06:00
|
|
|
}
|
|
|
|
|
|
2020-11-30 09:45:17 +05:30
|
|
|
func (*LogoutProvider) GetTrigger() string {
|
2021-01-04 11:32:29 +05:30
|
|
|
return CmdLogout
|
2016-02-01 18:52:43 -08:00
|
|
|
}
|
|
|
|
|
|
2021-02-26 08:12:49 +01:00
|
|
|
func (*LogoutProvider) GetCommand(a *app.App, T i18n.TranslateFunc) *model.Command {
|
2016-01-09 08:54:07 -06:00
|
|
|
return &model.Command{
|
2021-01-04 11:32:29 +05:30
|
|
|
Trigger: CmdLogout,
|
2016-01-09 08:54:07 -06:00
|
|
|
AutoComplete: true,
|
2017-03-13 09:23:16 -04:00
|
|
|
AutoCompleteDesc: T("api.command_logout.desc"),
|
2016-01-09 08:54:07 -06:00
|
|
|
AutoCompleteHint: "",
|
2017-03-13 09:23:16 -04:00
|
|
|
DisplayName: T("api.command_logout.name"),
|
2016-01-09 08:54:07 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-11 13:00:44 +03:00
|
|
|
func (*LogoutProvider) DoCommand(a *app.App, c *request.Context, args *model.CommandArgs, message string) *model.CommandResponse {
|
2020-06-23 08:33:45 -07:00
|
|
|
// Actual logout is handled client side.
|
|
|
|
|
return &model.CommandResponse{GotoLocation: "/login"}
|
2016-01-09 08:54:07 -06:00
|
|
|
}
|