diff --git a/client/src/auth/Auth.js b/client/src/auth/Auth.js index 44488c4ef..4a62b8251 100644 --- a/client/src/auth/Auth.js +++ b/client/src/auth/Auth.js @@ -101,8 +101,9 @@ class Auth { this.signinOrCreateAccount({ ...data }) this.cb(data) - console.log(authResult.idTokenPayload) + console.log('idTokenPayload', authResult.idTokenPayload) setItem('authUser', JSON.stringify(authResult.idTokenPayload)) + setItem('authId', authResult.idTokenPayload.sub) if (window.location.href.includes(`callback`)) { window.location.href = '/' } @@ -127,6 +128,7 @@ class Auth { console.log('signinOrCreateAccount auth: ', await data) setItem('authUser', JSON.stringify(data.data.authenticate)) + setItem('authId', data.data.authenticate.authId) if (window.location.href.includes(`callback`)) { window.location.href = '/' } else { @@ -169,6 +171,7 @@ class Auth { .then(result => { console.log('handleAuth.checksessions: ', result) setItem('authUser', result.idTokenPayload.sub) + setItem('authId', result.idTokenPayload.sub) // user confirmed, log into client this.setSession(result) return result.idTokenPayload diff --git a/client/src/components/Home.js b/client/src/components/Home.js index 71dfc717b..9d3e35e6e 100644 --- a/client/src/components/Home.js +++ b/client/src/components/Home.js @@ -90,17 +90,7 @@ class Home extends Component { Currently you can use the Browse section to list all registered users. At the Search page you can searh for users by name. Clicking on View Profile you can see some more info about that user. You can signup with your Github account and manage your profile information while logged in. While loggedin, you can edit your profile info, define your referrer and view your descendants. You will find all features under develpment with a dialog indicating it is not ready. - - What is next? - - - The major features for the 3rd sprint are: - - + diff --git a/client/src/components/LoggedInUser.js b/client/src/components/LoggedInUser.js index 8c06db481..656b66927 100644 --- a/client/src/components/LoggedInUser.js +++ b/client/src/components/LoggedInUser.js @@ -30,9 +30,12 @@ class LoggedInUser extends Component { user.lastName !== '' ) { displayName = user.firstName + ' ' + user.lastName } + let authArray = this.props.authId.split('|') + let identityProvider = authArray[0] + return (
-

+

) } else { diff --git a/client/src/components/LoggedInUserMenu.js b/client/src/components/LoggedInUserMenu.js index 0f5032229..692af39ff 100644 --- a/client/src/components/LoggedInUserMenu.js +++ b/client/src/components/LoggedInUserMenu.js @@ -13,6 +13,7 @@ import MenuItem from '@material-ui/core/MenuItem' // Images import GithubLogo from '../img/github-head-negative.png' +import EmailIcon from '../img/email.png' import ProfileIcon from '@material-ui/icons/Person' import LogoutIcon from '@material-ui/icons/DirectionsWalk' @@ -39,6 +40,24 @@ class LoggedInUserMenu extends Component { } } + displayIdentityProvider () { + const { classes } = this.props + switch (this.props.identityProvider) { + case 'github': + return ( + Github + ) + break + case 'auth0': + return ( + Auth0 + ) + break + default: + + } + } + render () { const { classes } = this.props return ( @@ -59,7 +78,7 @@ class LoggedInUserMenu extends Component { }} color='inherit' > - Github + {this.displayIdentityProvider()} {this.props.menuLabel} diff --git a/client/src/components/NavBar.js b/client/src/components/NavBar.js index 1853c20c2..ebd5ae5dd 100644 --- a/client/src/components/NavBar.js +++ b/client/src/components/NavBar.js @@ -56,20 +56,9 @@ class NavBar extends Component { } componentDidMount () { - const userStored = localStorage.getItem('authUser') - - if (userStored !== null && userStored !== undefined && userStored !== 'undefined') { - const user = JSON.parse(userStored) - - /* For some reason, the result of GraphQL some times varies, that is why I had to do the following hack. */ - - let authId - if (user.authId === undefined) { - authId = user.sub - } else { - authId = user.authId - } + const authId = localStorage.getItem('authId') + if (authId !== null && authId !== undefined && authId !== 'undefined') { this.setState({ authId: authId }) } } diff --git a/client/src/components/ProfileSheet.js b/client/src/components/ProfileSheet.js index 20510a91b..3e4b99539 100644 --- a/client/src/components/ProfileSheet.js +++ b/client/src/components/ProfileSheet.js @@ -22,6 +22,7 @@ import Typography from '@material-ui/core/Typography' // Images import GithubLogo from '../img/github-logo.png' +import Auth0Logo from '../img/auth0-logo.png' import AALogo from '../img/aa-logo.png' const styles = theme => ({ @@ -240,6 +241,7 @@ class ProfileSheet extends Component { componentWillMount () { if (this.defaultValuesSet === false) { + let authId = localStorage.getItem('authId') let userData = localStorage.getItem('loggedInUser') if (userData === 'undefined') { return } @@ -268,11 +270,37 @@ class ProfileSheet extends Component { isDeveloper: user.isDeveloper, isTrader: user.isTrader, isDataAnalyst: user.isDataAnalyst, - roleId: user.role.id + roleId: user.role.id, + authId: authId }) } } + displayIdentityProvider () { + const { classes } = this.props + let authId = this.state.authId + console.log('state', this.state) + if (authId !== undefined) { + let authArray = this.state.authId.split('|') + let identityProvider = authArray[0] + + switch (identityProvider) { + case 'github': + return ( + Github + ) + break + case 'auth0': + return ( + Auth0 + ) + break + default: + + } + } + } + render () { const { classes } = this.props return ( @@ -288,7 +316,7 @@ class ProfileSheet extends Component { - Github + {this.displayIdentityProvider()} diff --git a/client/src/img/auth0-logo.png b/client/src/img/auth0-logo.png new file mode 100644 index 000000000..ba4c72724 Binary files /dev/null and b/client/src/img/auth0-logo.png differ diff --git a/client/src/img/email.png b/client/src/img/email.png new file mode 100644 index 000000000..93b2edf0c Binary files /dev/null and b/client/src/img/email.png differ diff --git a/client/src/views/footer/index.js b/client/src/views/footer/index.js index 94fb59e20..dc9fd728f 100644 --- a/client/src/views/footer/index.js +++ b/client/src/views/footer/index.js @@ -58,7 +58,17 @@ const Footer = ({ classes }) => { - Users + Browse + + + + + Search + + + + + Contact @@ -68,15 +78,11 @@ const Footer = ({ classes }) => { - - + + Support - + { Documentation - + Telegram - + diff --git a/server/schema/schema.js b/server/schema/schema.js index b85a5b5a6..1ef24b2ae 100644 --- a/server/schema/schema.js +++ b/server/schema/schema.js @@ -425,7 +425,10 @@ function authenticate (encodedToken, callBackFunction) { let authArray = authId.split('|') let socialAccountProvider = authArray[0] - if (socialAccountProvider !== 'github') { + if ( + socialAccountProvider !== 'github' && + socialAccountProvider !== 'auth0' + ) { if (global.ERROR_LOG === true) { console.log('[ERROR] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> Social Account Provider not Supoorted. ') } if (global.ERROR_LOG === true) { console.log('[ERROR] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> socialAccountProvider = ' + socialAccountProvider) }