Auth0-lock documentation provides an example of attaching a listener to the authentication status change event:
https://auth0.com/docs/libraries/lock/v11#2-authenticating-and-getting-user-info
// Listening for the authenticated event
lock.on("authenticated", function(authResult) {
// Use the token in authResult to getUserInfo() and save it to localStorage
lock.getUserInfo(authResult.accessToken, function(error, profile) {
if (error) {
// Handle error
return;
}
document.getElementById('nick').textContent = profile.nickname;
localStorage.setItem('accessToken', authResult.accessToken);
localStorage.setItem('profile', JSON.stringify(profile));
});
});
API Reference for Auth0 Lock v11 provides more details about event types supported by on
, however nothing on the subject of removing a listener:
https://auth0.com/docs/libraries/lock/v11/api#on-
How do I remove a listener set up as per the example above?