Skip to content

Commit

Permalink
Merge branch 'pr/122'
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakaggarwal7 committed Jul 25, 2021
2 parents 9a53287 + 828bfee commit 095041d
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ const SocialLogin = (WrappedComponent) => class SocialLogin extends Component {
...prevState,
isLoaded: true
}), () => {
if (typeof this.props.onLoaded === 'function') {
this.props.onLoaded()
}
if (autoLogin || this.accessToken) {
if (this.fetchProvider && !this.accessToken) {
this.sdk.login(appId, redirect)
Expand Down Expand Up @@ -151,6 +154,7 @@ const SocialLogin = (WrappedComponent) => class SocialLogin extends Component {
isFetching: true
}), () => {
this.sdk.login().then(this.onLoginSuccess, this.onLoginFailure)
.catch(this.onLoginFailure)
})
} else if (this.state.isLoaded && this.state.isConnected) {
this.props.onLoginFailure('User already connected')
Expand Down Expand Up @@ -202,21 +206,15 @@ const SocialLogin = (WrappedComponent) => class SocialLogin extends Component {
onLoginFailure (err) {
const { onLoginFailure } = this.props

if (this.node) {
this.setState((prevState) => ({
...prevState,
isFetching: false,
isConnected: false
}), () => {
if (typeof onLoginFailure === 'function') {
onLoginFailure(err)
}
})
} else {
this.setState((prevState) => ({
...prevState,
isFetching: false,
isConnected: false
}), () => {
if (typeof onLoginFailure === 'function') {
onLoginFailure(err)
}
}
})
}

/**
Expand Down

0 comments on commit 095041d

Please sign in to comment.