Clean up /logout command flow and errors (#4918)

This commit is contained in:
Joram Wilander
2016-12-30 13:12:43 -05:00
committed by Christopher Speller
parent 28a7a2f200
commit 2a91e5e031
4 changed files with 19 additions and 14 deletions

View File

@@ -34,7 +34,7 @@ func (me *LogoutProvider) GetCommand(c *Context) *model.Command {
func (me *LogoutProvider) DoCommand(c *Context, args *model.CommandArgs, 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")}
SUCCESS := &model.CommandResponse{GotoLocation: "/login"}
// 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 != "" {

View File

@@ -571,10 +571,6 @@
"id": "api.command_logout.name",
"translation": "logout"
},
{
"id": "api.command_logout.success_message",
"translation": "Logging out..."
},
{
"id": "api.command_me.desc",
"translation": "Do an action"

View File

@@ -476,15 +476,7 @@ export function emitUserLoggedOutEvent(redirectTo = '/', shouldSignalLogout = tr
BrowserStore.signalLogout();
}
BrowserStore.clear();
ErrorStore.clearLastError();
PreferenceStore.clear();
UserStore.clear();
TeamStore.clear();
newLocalizationSelected(global.window.mm_config.DefaultClientLocale);
stopPeriodicStatusUpdates();
WebsocketActions.close();
browserHistory.push(redirectTo);
clientLogout(redirectTo);
},
() => {
browserHistory.push(redirectTo);
@@ -492,6 +484,18 @@ export function emitUserLoggedOutEvent(redirectTo = '/', shouldSignalLogout = tr
);
}
export function clientLogout(redirectTo = '/') {
BrowserStore.clear();
ErrorStore.clearLastError();
PreferenceStore.clear();
UserStore.clear();
TeamStore.clear();
newLocalizationSelected(global.window.mm_config.DefaultClientLocale);
stopPeriodicStatusUpdates();
WebsocketActions.close();
browserHistory.push(redirectTo);
}
export function emitSearchMentionsEvent(user) {
let terms = '';
if (user.notify_props && user.notify_props.mention_keys) {

View File

@@ -125,6 +125,11 @@ export default class CreatePost extends React.Component {
(data) => {
this.setState({submitting: false});
if (post.message.trim() === '/logout') {
GlobalActions.clientLogout(data.goto_location);
return;
}
if (data.goto_location && data.goto_location.length > 0) {
browserHistory.push(data.goto_location);
}