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

Этот коммит содержится в:
Joram Wilander
2016-12-30 13:12:43 -05:00
коммит произвёл Christopher Speller
родитель 28a7a2f200
Коммит 2a91e5e031
4 изменённых файлов: 19 добавлений и 14 удалений

Просмотреть файл

@@ -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 { 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")} 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 // 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 != "" { if c.Session.Id != "" {

Просмотреть файл

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

Просмотреть файл

@@ -476,6 +476,15 @@ export function emitUserLoggedOutEvent(redirectTo = '/', shouldSignalLogout = tr
BrowserStore.signalLogout(); BrowserStore.signalLogout();
} }
clientLogout(redirectTo);
},
() => {
browserHistory.push(redirectTo);
}
);
}
export function clientLogout(redirectTo = '/') {
BrowserStore.clear(); BrowserStore.clear();
ErrorStore.clearLastError(); ErrorStore.clearLastError();
PreferenceStore.clear(); PreferenceStore.clear();
@@ -485,11 +494,6 @@ export function emitUserLoggedOutEvent(redirectTo = '/', shouldSignalLogout = tr
stopPeriodicStatusUpdates(); stopPeriodicStatusUpdates();
WebsocketActions.close(); WebsocketActions.close();
browserHistory.push(redirectTo); browserHistory.push(redirectTo);
},
() => {
browserHistory.push(redirectTo);
}
);
} }
export function emitSearchMentionsEvent(user) { export function emitSearchMentionsEvent(user) {

Просмотреть файл

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