diff --git a/www/res/access-multiple.js b/www/res/access-multiple.js
index 3322fd4..f3cdee4 100644
--- a/www/res/access-multiple.js
+++ b/www/res/access-multiple.js
@@ -129,7 +129,7 @@ function render() {
main.className = 'overview';
main.innerHTML = `
${CLIENTS[client].name}
`;
- updateOverview(client).then();
+ update();
} else {
window.location.hash = `#/${client}`;
}
@@ -142,7 +142,17 @@ function update() {
// do nothing
} else {
if (hash === `#/${client}`) {
- updateOverview(client).then();
+ updateOverview(client)
+ .then()
+ .catch(e => {
+ if (e instanceof ApiError && e.statusCode === 401) {
+ window.localStorage.removeItem(`${CLIENT}/${client}/token`);
+ window.localStorage.removeItem(`${CLIENT}/${client}/password`);
+ window.location.hash = `#/${client}/login`;
+ } else {
+ alert(e.localizedMessage ?? ERROR_MESSAGES[e.message] ?? `Unbekannter Fehler: ${e.message}`);
+ }
+ });
}
}
}
@@ -172,7 +182,7 @@ function actionLogin(form) {
}).catch(e => {
const error = document.createElement('div');
error.className = 'error';
- error.innerText = e.localizedMessage ?? ERROR_MESSAGES[e.message] ?? 'Unbekannter Fehler';
+ error.innerText = e.localizedMessage ?? ERROR_MESSAGES[e.message] ?? `Unbekannter Fehler\n(${e.message})`;
form.insertBefore(error, form.lastChild.previousSibling);
});
diff --git a/www/res/access.js b/www/res/access.js
index 6c7de61..572d7d5 100644
--- a/www/res/access.js
+++ b/www/res/access.js
@@ -8,6 +8,7 @@ const ERROR_MESSAGES = {
class ApiError extends Error {
constructor(statusCode, message) {
super(statusCode + ' - ' + message);
+ this.statusCode = statusCode;
this.name = 'ApiError';
this.localizedMessage = ERROR_MESSAGES[statusCode];
}