hello.js icon indicating copy to clipboard operation
hello.js copied to clipboard

When using display: 'page' the login callback is not fired

Open alexgurr opened this issue 9 years ago • 2 comments

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();
                });
        }
    );

alexgurr avatar Mar 04 '17 18:03 alexgurr

Your redirecting the entire page, so any handlers you set up will be destroyed. Define hello.on('auth', loginHandler) to fire on page load.

MrSwitch avatar Mar 06 '17 11:03 MrSwitch

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"); }); });

nbangera avatar Feb 14 '19 12:02 nbangera