FIX: Remove all service workers from Apple devices *again*

There is a bug that when Safari starts up, and reloads the tabs from
the previous session **and** there is a service worker registered for
the scope of the document, all cookies marked as `SameSite=Lax` won't be
sent in the request.

This puts Discourse in a **very** broken state, where:

- You appear as a anon user
- Subsequent xhr requests will come with logged in data
- Refreshing doesn't log you in (cookies are still not sent)
- Clicking on the address bar and hitting enter, will log you in (as it
will finally send those damn `SameSite=Lax` cookies.

Looks a lot like a corner case missed by the fix at
https://trac.webkit.org/changeset/241918/webkit
This commit is contained in:
Rafael dos Santos Silva 2019-07-16 19:30:38 -03:00
parent a571efba35
commit 2a0cd066a7

View File

@ -9,7 +9,9 @@ export default {
const isSupported = isSecured && "serviceWorker" in navigator;
if (isSupported) {
if (Discourse.ServiceWorkerURL) {
const isApple = !!navigator.platform.match(/(Mac|iPhone|iPod|iPad)/i);
if (Discourse.ServiceWorkerURL && !isApple) {
navigator.serviceWorker.getRegistrations().then(registrations => {
for (let registration of registrations) {
if (