[bug] Don't try per user auto-login if basic auth disabled

a1352d817ae3e07598423b82cc63ad136c74c20d

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +4 -3Showing whitespace changes
server.js+1 -1
@@ -363,7 +363,7 @@ app.get('/login', async (request, response) => {
363 }363 }
364364
365 try {365 try {
366 const autoLogin = await userModule.tryAutoLogin(request);366 const autoLogin = await userModule.tryAutoLogin(request, basicAuthMode);
367367
368 if (autoLogin) {368 if (autoLogin) {
369 return response.redirect('/');369 return response.redirect('/');
src/users.js+3 -2
@@ -571,9 +571,10 @@ function shouldRedirectToLogin(request) {
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 basic572 * or another configured method such authlia or basic
573 * @param {import('express').Request} request Request object573 * @param {import('express').Request} request Request object
574 * @param {boolean} basicAuthMode If Basic auth mode is enabled
574 * @returns {Promise<boolean>} Whether auto-login was performed575 * @returns {Promise<boolean>} Whether auto-login was performed
575 */576 */
576async function tryAutoLogin(request) {577async function tryAutoLogin(request, basicAuthMode) {
577 if (!ENABLE_ACCOUNTS || request.user || !request.session) {578 if (!ENABLE_ACCOUNTS || request.user || !request.session) {
578 return false;579 return false;
579 }580 }
@@ -587,7 +588,7 @@ async function tryAutoLogin(request) {
587 return true;588 return true;
588 }589 }
589590
590 if (PER_USER_BASIC_AUTH && await basicUserLogin(request)) {591 if (basicAuthMode && PER_USER_BASIC_AUTH && await basicUserLogin(request)) {
591 return true;592 return true;
592 }593 }
593 }594 }