Not a bug Admins lose push notifications whenever logging in to ACP

Mika_M

Member
Affected version
2.2.11
Admins push notifications become disabled every time when admin logs in to admin control panel. Is this planned behaviour or a bug?

We do understand that users push notifications turn off if user logs out from forum itself. But should they really turn off when visiting ACP?

This was found with version 2.2.11 but we also have a test environment with 2.2.12 and it shows similar behaviour.
 
Last edited:
Upon further inspection, push notifications are disabled when loading admin.php. No logging in to ACP is needed for this to happen, just loading the login page itself is enough.

This seems to be planned behaviour, at least kind of. At this point browser is subscribed to push notifications but there is no userId because user has not yet logged in to ACP.

For security reasons push notifications are then disabled to avoid leaking them to unauthenticated users. Which is kind of right, but seems like a bug to happen at this point, before allowing admin log in to ACP.

JavaScript:
function getSubscription()
        {
            XF.PWA.getRegistration()
                .then(function(registration)
                {
                    return registration.pushManager.getSubscription();
                })
                .then(function(subscription)
                {
                    XF.Push.isSubscribed = !(subscription === null);

                    if (XF.Push.isSubscribed)
                    {
                        $(document).trigger('push:init-subscribed');

                        // If the browser is subscribed, but there is no userId then
                        // we should unsubscribe to avoid leaking notifications to
                        // unauthenticated users on a shared device.
                        // If the server key doesn't match, then we should unsubscribe as we'd
                        // need to resubscribe with the new key.
                        if (XF.config.userId && isExpectedServerKey(subscription))
                        {
                            XF.Push.updateUserSubscription(subscription, 'update');
                        }
                        else
                        {
                            subscription.unsubscribe();
                            XF.Push.updateUserSubscription(subscription, 'unsubscribe');
                        }
                    }
                    else
                    {
                        $(document).trigger('push:init-unsubscribed');
                    }
                });
        }
 
We do not experience the error.
No matter how many times a day I log in to the admin page I still get push notifications.
Can it be that the corresponding admin has a browser problem?
 
This is confirmed and can be replicated by all our admins. I believe we are all using Chrome browser.

Does not even need the actual login to ACP, push notifications get disabled every time the ACP login page is loaded.
 
Okay, that sounds strange.
I can't reproduce this as already mentioned.

I have now tested this again with different browsers. Push notifications are not deactivated in our case.
We are still using version 2.2.11. Maybe that's the reason.
But maybe someone else can confirm the problem.
 
Okay, this might have been self-inflicted. Earlier we made a template modification to notice_enable_push in effort to hide push notifications advertising from our users.

Commenting out everything except <xf:js> at the bottom did what we wanted to but apparently also caused this problem. So not a bug after all.
 
Back
Top Bottom