The onUnload method should check if an unRegisterUrl was defined

The onUnload method in ss-utils.js should check if an unRegisterUrl was defined:

$.ss.onUnload = function () {
    // Check if unRegisterUrl was set
    if (!unRegisterUrl)
        return;

    if (navigator.sendBeacon)
        navigator.sendBeacon($.ss.unRegisterUrl);
    else
        $.ajax({ type: 'POST', url: $.ss.unRegisterUrl, async: false });
};

Otherwise an invalid url will be called.

br,
Alex

Sure, done in this commit and the stand-alone ss-utils, it was already guarded in @servicestack/client ServerEventsClient.

Our of curiosity as this is pre-configured by the server, what’s the rationale for unsetting it?

I did this to prevent the session from being logged out when the browser is reloaded.
Maybe there is a better way to prevent this, but it does the trick.

1 Like