From 74d2c18943f92db88d24c50448f27ed19cabe056 Mon Sep 17 00:00:00 2001 From: Magnus Hoff Date: Wed, 29 Nov 2017 12:53:41 +0100 Subject: [PATCH] Use heuristic to guess that we hit a login redirect on saving --- assets/script.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/script.js b/assets/script.js index 30e781b..0f97707 100644 --- a/assets/script.js +++ b/assets/script.js @@ -98,8 +98,12 @@ function openEditor() { credentials: "same-origin", } ).then(response => { - if ((response.status === 401) && (response.headers.has("location"))) { - return loginDialog(response.headers.get("location")) + // I don't know how to more precisely determine that we hit a login redirect: + const probablyLoginRedirect = response.redirected && + (response.headers.get("content-type") !== "application/json"); + + if (probablyLoginRedirect) { + return loginDialog(response.url) .then(() => { textarea.disabled = false; });