15736: Make sure to save sessions from state not local 15736-site-mgr
authorPeter Amstutz <pamstutz@veritasgenetics.com>
Tue, 5 Nov 2019 21:12:09 +0000 (16:12 -0500)
committerPeter Amstutz <pamstutz@veritasgenetics.com>
Tue, 5 Nov 2019 21:12:09 +0000 (16:12 -0500)
src/store/auth/auth-action-session.ts

index 1c9d1d14114bdea3feb1fe93ba8555e585ba6811..5b8acf9aeb061651b656590cd496c4a2d9e8bad8 100644 (file)
@@ -203,7 +203,7 @@ export const validateSessions = () =>
                     }
                 }
             }
-            services.authService.saveSessions(sessions);
+            services.authService.saveSessions(getState().auth.sessions);
             dispatch(progressIndicatorActions.STOP_WORKING("sessionsValidation"));
         }
     };
@@ -246,9 +246,9 @@ export const addSession = (remoteHost: string, token?: string, sendToLogin?: boo
                 };
 
                 if (sessions.find(s => s.clusterId === config.uuidPrefix)) {
-                    dispatch(authActions.UPDATE_SESSION(session));
+                    await dispatch(authActions.UPDATE_SESSION(session));
                 } else {
-                    dispatch(authActions.ADD_SESSION(session));
+                    await dispatch(authActions.ADD_SESSION(session));
                 }
                 services.authService.saveSessions(getState().auth.sessions);
 
@@ -302,7 +302,6 @@ export const toggleSession = (session: Session) =>
 export const initSessions = (authService: AuthService, config: Config, user: User) =>
     (dispatch: Dispatch<any>) => {
         const sessions = authService.buildSessions(config, user);
-        authService.saveSessions(sessions);
         dispatch(authActions.SET_SESSIONS(sessions));
         dispatch(validateSessions());
     };