Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock 10.11.0 - authentication event emitted on authorization dialog cancel #890

Closed
4 tasks done
jwarykowski opened this issue Mar 2, 2017 · 4 comments · Fixed by auth0/auth0.js#395
Closed
4 tasks done
Assignees

Comments

@jwarykowski
Copy link

jwarykowski commented Mar 2, 2017

Overview

Lock authenticated event emitted when the user closes the authorization dialog by clicking cancel. I would expect this to raise the authorization_error event, however, it believes authorization was successful.

I haven't trawled through the code as of yet but wanted to raise an initial issue to see if this problem is known. If so is there a recommended workaround?

  • Code snippet - see below
  • Screenshots - see below
  • Lock version - v10.11.0
  • Browser & OS - Chrome / Mac OS Sierra

iftdvdwu7v

Original recording here http://recordit.co/IftdvdWU7V.

export function authenticate() {
  const AUTH0_CLIENT_ID = 'xxxxxxxxxxx'
  const AUTH0_DOMAIN = 'xxxxxxxxxxx'

  const lock = new Auth0Lock(AUTH0_CLIENT_ID, AUTH0_DOMAIN, {
    auth: { redirect: false },
    allowedConnections: ['spotify'],
    languageDictionary: { title: 'Testing!!' },
  })

  return dispatch => {
    lock.on('authenticated', (authResult) => {
      console.log(authResult) // error here!!

      if (authResult.errorDescription) return dispatch(authError(authResult.errorDescription))

      lock.getUserInfo(authResult, (error, profile) => {
        if (error) return dispatch(authError(error.errorDescription))

        localStorage.setItem('accessToken', authResult.accessToken)

        return dispatch(authSuccess(profile))
      })
    })

    lock.on('authorization_error', (error) => {
      return dispatch(authError(error.errorDescription))
    })

    lock.on('unrecoverable_error', (error) => lock.hide())

    lock.show()
  }
}

Code above returns a function for redux thunk.

@jwarykowski
Copy link
Author

@luisrudge did you have a chance to look into this? Happy to look into this if needed.

@luisrudge
Copy link
Contributor

Hi @jonathanchrisp. I'm still trying to find a reasonable fix for this, but it might take a while. For now, you can use auth: { redirect: false, responseType: 'code' }, instead, it will work just fine. The issue is when you use responseType: token (the default). Does that work for you right now?

@luisrudge
Copy link
Contributor

@jonathanchrisp sorry! nevermind what I said before. I found the root cause of the issue and I'll fix it for the next release. Also, responseType code wouldn't work any way 😭

@luisrudge
Copy link
Contributor

This was fixed in auth0/auth0.js#395 and will be in the next release! Thanks for your patience and all the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants