From 2a0cd066a77322d141200af32d7c63363ffb4b41 Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Tue, 16 Jul 2019 19:30:38 -0300 Subject: [PATCH] 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 --- .../discourse/initializers/register-service-worker.js.es6 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/initializers/register-service-worker.js.es6 b/app/assets/javascripts/discourse/initializers/register-service-worker.js.es6 index 92ae9886256..b78044e11f3 100644 --- a/app/assets/javascripts/discourse/initializers/register-service-worker.js.es6 +++ b/app/assets/javascripts/discourse/initializers/register-service-worker.js.es6 @@ -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 (