Use heuristic to guess that we hit a login redirect on saving

This commit is contained in:
Magnus Hoff 2017-11-29 12:53:41 +01:00
parent 2e406f4480
commit 74d2c18943

View file

@ -98,8 +98,12 @@ function openEditor() {
credentials: "same-origin", credentials: "same-origin",
} }
).then(response => { ).then(response => {
if ((response.status === 401) && (response.headers.has("location"))) { // I don't know how to more precisely determine that we hit a login redirect:
return loginDialog(response.headers.get("location")) const probablyLoginRedirect = response.redirected &&
(response.headers.get("content-type") !== "application/json");
if (probablyLoginRedirect) {
return loginDialog(response.url)
.then(() => { .then(() => {
textarea.disabled = false; textarea.disabled = false;
}); });