diff --git a/client/src/auth/index.js b/client/src/auth/index.js index e7d84336c..a8528584d 100644 --- a/client/src/auth/index.js +++ b/client/src/auth/index.js @@ -128,7 +128,7 @@ class Auth { }) console.log('signinOrCreateAccount auth: ', await data) - setItem('user', data.data.authenticate.authId) + setItem('user', JSON.stringify(data.data.authenticate)) if (window.location.href.includes(`callback`)) { window.location.href = '/' } else { diff --git a/client/src/components/LoggedInUser.js b/client/src/components/LoggedInUser.js index 71c3e6ab4..196618322 100644 --- a/client/src/components/LoggedInUser.js +++ b/client/src/components/LoggedInUser.js @@ -11,6 +11,9 @@ class LoggedInUser extends Component { const user = this.props.data.userByAuthId; + console.log('loggedInUser'); + console.log(user); + if(user){ console.log(user.firstName); diff --git a/client/src/components/NavBar.js b/client/src/components/NavBar.js index b590ef192..dca0cce59 100644 --- a/client/src/components/NavBar.js +++ b/client/src/components/NavBar.js @@ -49,24 +49,13 @@ class NavBar extends Component { } componentDidMount() { - /* - this._asyncRequest = window.localStorage.getItem('user').then( - response => { - this._asyncRequest = null; - let user = JSON.parse(response) - if (user) { - const authId = user.sub; - this.setState({ authId: authId }); - } - } - ); - */ + const userStored = localStorage.getItem('user'); console.log(userStored); if (userStored !== null && userStored !== undefined && userStored !== 'undefined') { const user = JSON.parse(userStored); - const authId = user.sub; + const authId = user.authId; this.setState({ authId: authId }); } }