| @@ -180,7 +180,13 @@ function displayError(message) { | |||
| 180 | * Preserves the query string. | 180 | * Preserves the query string. |
| 181 | */ | 181 | */ |
| 182 | function redirectToHome() { | 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 | headers: getRequestHeaders(), | 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 | * Tries auto-login if there is only one user and it's not password protected. | 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 | * @param {import('express').Request} request Request object | 573 | * @param {import('express').Request} request Request object |
| 573 | * @returns {Promise<boolean>} Whether auto-login was performed | 574 | * @returns {Promise<boolean>} Whether auto-login was performed |
| 574 | */ | 575 | */ |
| @@ -577,16 +578,19 @@ async function tryAutoLogin(request) { | |||
| 577 | return false; | 578 | return false; |
| 578 | } | 579 | } |
| 579 | 580 | ||
| 580 | if (await singleUserLogin(request)) { | 581 | console.warn(request.session.noauto); |
| 581 | return true; | 582 | if (!request.query.noauto) { |
| 582 | } | 583 | if (await singleUserLogin(request)) { |
| 584 | return true; | ||
| 585 | } | ||
| 583 | 586 | ||
| 584 | if (AUTHELIA_AUTH && await autheliaUserLogin(request)) { | 587 | if (AUTHELIA_AUTH && await autheliaUserLogin(request)) { |
| 585 | return true; | 588 | return true; |
| 586 | } | 589 | } |
| 587 | 590 | ||
| 588 | if (PERUSER_BASIC_AUTH && await basicUserLogin(request)) { | 591 | if (PERUSER_BASIC_AUTH && await basicUserLogin(request)) { |
| 589 | return true; | 592 | return true; |
| 593 | } | ||
| 590 | } | 594 | } |
| 591 | 595 | ||
| 592 | return false; | 596 | return false; |