Closed saikat closed 7 years ago
Hey, did you manage to solve your problem. it seems that it only returns to the url where you call this.lock.show()
at. if you log in from localhosat:3000
, it returns to localhosat:3000
after authenticating. if you log in from localhosat:3000/signin
, it returns to localhosat:3000/signin
. just doesnt make sense to me.
If you specify redirectUrl (in Lock 10) or callback URL (in Lock 9), you can tell it where to go. E.g. this is what my lock.show call looks like (using Lock 10). And then I'm using the 'state' param to keep track of where the user should be sent after a successful login. So in this case, the AUTH0_LOGIN_CALLBACK URL is just a URL on my server that then handles doing another redirect to nextUrl:
export function login(nextUrl) {
const lock = new Auth0Lock(window.AUTH0_CLIENT_ID, window.AUTH0_CLIENT_URL, {
auth: {
redirect: true,
redirectUrl: window.AUTH0_LOGIN_CALLBACK,
responseType: 'code',
params: {
state: nextUrl
}
},
closable: false,
additionalSignUpFields: [{
name: 'given_name',
placeholder: 'first name'
}, {
name: 'family_name',
placeholder: 'last name'
}, {
name: 'cell',
placeholder: 'cell phone'
}]
})
lock.show()
}
Closing this out as the samples have been deprecated in favor the latest ones :)
With this sample app, if you try to go to localhost:3000/home and are not logged in, you get a login popup as expected. But after logging in, you get an error about "localhost:3000/home" not being in the list of allowed callback URLs. If there were more routes on this app that were auth-protected, how could you redirect to the original route without always running into the issue of allowed callback URLs (unless you hardcode in every possible route in Auth0)?