When using display: 'page' the login callback is not fired
If I set display to default, the callback function is correctly fired. If the display is set to page, the redirect occurs successfully back to the original page, but then the callback is never fired?
hello.login(
'battlenet',
{
scope: 'wow.profile',
display: backgroundLogin ? 'none' : 'page',
},
() => {
console.log('login success');
const accessToken = hello('battlenet').getAuthResponse();
const expiryDate = getExpiryDate(accessToken.expires_in);
console.log('setting user data', expiryDate);
setUserData({ expiryDate });
getUserChars()
.then(response => {
setUserData({ chars: response.characters }, false);
updateHeaderOnLogin();
});
}
);
Your redirecting the entire page, so any handlers you set up will be destroyed. Define hello.on('auth', loginHandler) to fire on page load.
I want to set a cookie only once when user is successfully authenticated
could not set it on hello('network').login as the callback is not triggered cant set it on hello.on('auth.login') as this event is triggered on every page load. and it does not tell me if user had initiated the login event.
Is hello.on('auth') right event to add this logic. Also tried registering "auth" event it does not get fired on successfull login.
$(function () { hello.on('auth', function (auth) { console.log("auth triggered"); }); });