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 удалений

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

@@ -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) {

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

@@ -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);
}