From 2a91e5e031d9490f8364d55cb023d384d56f047f Mon Sep 17 00:00:00 2001
From: Joram Wilander <jwawilander@gmail.com>
Date: Fri, 30 Dec 2016 13:12:43 -0500
Subject: Clean up /logout command flow and errors (#4918)

---
 webapp/actions/global_actions.jsx | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

(limited to 'webapp/actions/global_actions.jsx')

diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx
index 5ee1e16a5..f1714def2 100644
--- a/webapp/actions/global_actions.jsx
+++ b/webapp/actions/global_actions.jsx
@@ -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) {
-- 
cgit v1.2.3-1-g7c22

