From d6992fe7342cbda0539a4937feca0da409cb59cc Mon Sep 17 00:00:00 2001 From: irismarie Date: Fri, 5 Feb 2021 17:37:21 +0100 Subject: [PATCH] wait before redirecting --- src/user/login-complete.js | 14 ++++++++------ src/user/login-store.js | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/user/login-complete.js b/src/user/login-complete.js index 8397720..3bca1f7 100644 --- a/src/user/login-complete.js +++ b/src/user/login-complete.js @@ -63,9 +63,9 @@ class LoginComplete extends React.Component { } } - componentDidUnmount() { + stopTimer() { console.log("component unmounting"); - //clearInterval(this.timer); + clearInterval(this.timer); } startTimer() { @@ -93,13 +93,15 @@ class LoginComplete extends React.Component { if (this.state.currentUser && this.state.currentUser !== "") { console.log("user:"); console.log(this.state.currentUser); + this.stopTimer(); return (); } - else if (this.state.secondsToWait > 0) { - return (

Authenticating.. {this.state.secondsToWait}

); - } else { // authenticating failed - //NotificationsFactory.LOAD_ERROR('Backend did not return user after external auth'); + else if (this.state.secondsToWait == 0) { + this.stopTimer(); return (); + } else { // authenticating failed + //NotificationsFactory.LOAD_ERROR('Backend did not return user after external auth'); + return (

Authenticating.. {this.state.secondsToWait}

); } } } diff --git a/src/user/login-store.js b/src/user/login-store.js index c553e17..c236639 100644 --- a/src/user/login-store.js +++ b/src/user/login-store.js @@ -58,6 +58,8 @@ class LoginStore extends ReduceStore { console.log(action); localStorage.setItem('token', action.token); localStorage.setItem('currentUser', JSON.stringify(action.currentUser)); + console.log(localStorage.getItem('token')); + console.log(localStorage.getItem("currentUser")); return Object.assign({}, state, { token: action.token, currentUser: action.currentUser});