Login BUG fixed, both Github and Auth0 logins working well.

This commit is contained in:
Luis Fernando Molina committed 2018-10-03 14:01:02 +02:00
1 parent c0a4ead100
commit 8b2dc0b52e
5 files changed
+48 -55

No files matched your search

+4 -1
View File
@@ -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
+1 -11
View File
@@ -90,17 +90,7 @@ class Home extends Component {
<Typography className={classes.typography} component='p'>
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.
</Typography>
<Typography className={classes.typography} gutterBottom variant='headline' component='h2'>
What is next?
</Typography>
<Typography className={classes.typography} component='p'>
The major features for the 3rd sprint are:
</Typography>
<ul>
<li>1. Managing profile images.</li>
<li>2. Making sure that Auth0 integration server side is working well.</li>
<li>3. Making sure that mutations can not be impersonated.</li>
</ul>
</Grid>
</Grid>
+2 -13
View File
@@ -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 })
}
}
+21 -20
View File
@@ -241,16 +241,14 @@ class ProfileSheet extends Component {
componentWillMount () {
if (this.defaultValuesSet === false) {
let authUserData = localStorage.getItem('authUser')
let authId = localStorage.getItem('authId')
let userData = localStorage.getItem('loggedInUser')
if (userData === 'undefined' || authUserData === 'undefined') { return }
if (userData === 'undefined') { return }
let user = JSON.parse(userData)
this.defaultValuesSet = true
let authUser = JSON.parse(authUserData)
/* To avoid console warning, we need to take care of the fields that are null. */
if (user.firstName === null) { user.firstName = '' }
@@ -273,30 +271,33 @@ class ProfileSheet extends Component {
isTrader: user.isTrader,
isDataAnalyst: user.isDataAnalyst,
roleId: user.role.id,
authId: authUser.authId
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]
let authArray = this.state.authId.split('|')
let identityProvider = authArray[0]
switch (identityProvider) {
case 'github':
return (
<img className={classes.img} src={GithubLogo} alt='Github' />
)
break
case 'auth0':
return (
<img className={classes.img} src={Auth0Logo} alt='Auth0' />
)
break
default:
switch (identityProvider) {
case 'github':
return (
<img className={classes.img} src={GithubLogo} alt='Github' />
)
break
case 'auth0':
return (
<img className={classes.img} src={Auth0Logo} alt='Auth0' />
)
break
default:
}
}
}
+20 -10
View File
@@ -58,7 +58,17 @@ const Footer = ({ classes }) => {
</NavLink>
<NavLink to='/browse' className={classNames(classes.footerLink)}>
<Typography variant='subheading' color='textSecondary'>
Users
Browse
</Typography>
</NavLink>
<NavLink to='/search' className={classNames(classes.footerLink)}>
<Typography variant='subheading' color='textSecondary'>
Search
</Typography>
</NavLink>
<NavLink to='/contact' className={classNames(classes.footerLink)}>
<Typography variant='subheading' color='textSecondary'>
Contact
</Typography>
</NavLink>
<NavLink to='/about' className={classNames(classes.footerLink)}>
@@ -68,15 +78,11 @@ const Footer = ({ classes }) => {
</NavLink>
</Grid>
<Grid item xs>
<a
href='https://t.me/advancedalgoscommunity'
target='_blank>'
className={classNames(classes.footerLink)}
>
<Typography variant='title' color='textPrimary' gutterBottom>
<Typography variant='title' color='textPrimary' gutterBottom>
Support
</Typography>
</a>
<a
href='https://advancedalgos.net/documentation-quick-start.shtml'
target='_blank>'
@@ -86,11 +92,15 @@ const Footer = ({ classes }) => {
Documentation
</Typography>
</a>
<NavLink to='/' className={classNames(classes.footerLink)}>
<a
href='https://t.me/advancedalgoscommunity'
target='_blank>'
className={classNames(classes.footerLink)}
>
<Typography variant='subheading' color='textSecondary'>
Telegram
</Typography>
</NavLink>
</a>
</Grid>
<Grid item xs>
<Typography variant='title' color='textPrimary' gutterBottom>