auth0-blog / redux-auth

MIT License
384 stars 68 forks source link

Auth0-lock branch should be updated #20

Open camel113 opened 7 years ago

camel113 commented 7 years ago

I think that the current example is not working anymore. I am currently using v 10.6.1. And for redux, react, and auth0 working together I did some change to the login function in action.js. First you have to set redirect:falsewhen declaring Auth0Lock. If you are not doing it the page will be refreshed and your async function will never be called. Then you need to use lock.on to get event from Auth0Lock and calling your actions. Below a short example.

export function login() {
    console.log("login()")
  const lock = new Auth0Lock('xx', 'xx.eu.auth0.com',{auth:{redirect:false}});
  return dispatch => {
    lock.show()
    lock.on('authenticated', function(authResult){
        localStorage.setItem('idToken', authResult.idToken);
        dispatch(lockSuccess(authResult.profile, authResult.token))
    })
  }
}

What do you think?

jasonkim commented 6 years ago

This helped me a bit to understand. More specifically, it looks like there needs some way to process the successful login after the redirect happens. (that is if you do want the redirect)

https://github.com/amaurymartiny/react-redux-auth0-kit/blob/master/src/containers/App/AppView.js

HirenPatel2791 commented 5 years ago

Hi, any updates on this, the current example doesn't work with latest react and lock :(