| @@ -180,7 +180,13 @@ function displayError(message) { | ||
| 180 | 180 | * Preserves the query string. |
| 181 | 181 | */ |
| 182 | 182 | function redirectToHome() { |
| 183 | - window.location.href = '/' + window.location.search; | |
| 183 | + // After a login theres no need to preserve the | |
| 184 | + // noauto (if present) | |
| 185 | + const urlParams = new URLSearchParams(window.location.search); | |
| 186 | + | |
| 187 | + urlParams.delete('noauto'); | |
| 188 | + | |
| 189 | + window.location.href = '/' + urlParams.toString(); | |
| 184 | 190 | } |
| 185 | 191 | |
| 186 | 192 | /** |
| @@ -848,7 +848,14 @@ async function logout() { | ||
| 848 | 848 | headers: getRequestHeaders(), |
| 849 | 849 | }); |
| 850 | 850 | |
| 851 | - window.location.reload(); | |
| 851 | + // On an explicit logout stop auto login | |
| 852 | + // to allow user to change username even | |
| 853 | + // when auto auth (such as authelia or basic) | |
| 854 | + // would be valid | |
| 855 | + const urlParams = new URLSearchParams(window.location.search); | |
| 856 | + urlParams.set('noauto', 'true'); | |
| 857 | + | |
| 858 | + window.location.search = urlParams.toString(); | |
| 852 | 859 | } |
| 853 | 860 | |
| 854 | 861 | /** |
| @@ -569,6 +569,7 @@ function shouldRedirectToLogin(request) { | ||
| 569 | 569 | |
| 570 | 570 | /** |
| 571 | 571 | * Tries auto-login if there is only one user and it's not password protected. |
| 572 | + * or another configured method such authlia or basic | |
| 572 | 573 | * @param {import('express').Request} request Request object |
| 573 | 574 | * @returns {Promise<boolean>} Whether auto-login was performed |
| 574 | 575 | */ |
| @@ -577,6 +578,8 @@ async function tryAutoLogin(request) { | ||
| 577 | 578 | return false; |
| 578 | 579 | } |
| 579 | 580 | |
| 581 | + console.warn(request.session.noauto); | |
| 582 | + if (!request.query.noauto) { | |
| 580 | 583 | if (await singleUserLogin(request)) { |
| 581 | 584 | return true; |
| 582 | 585 | } |
| @@ -588,6 +591,7 @@ async function tryAutoLogin(request) { | ||
| 588 | 591 | if (PERUSER_BASIC_AUTH && await basicUserLogin(request)) { |
| 589 | 592 | return true; |
| 590 | 593 | } |
| 594 | + } | |
| 591 | 595 | |
| 592 | 596 | return false; |
| 593 | 597 | } |