From 65f31d79daa5622fbe91df87d9590cbe9efed86b Mon Sep 17 00:00:00 2001 From: filesite Date: Mon, 9 Sep 2024 23:15:11 +0800 Subject: [PATCH] improve password auth check --- plugins/Common.php | 6 +++--- themes/beauty/views/site/index.php | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/Common.php b/plugins/Common.php index 23869fb..63c303b 100644 --- a/plugins/Common.php +++ b/plugins/Common.php @@ -657,10 +657,10 @@ Class Common { $allowed = true; $authDirs = self::getPwdAuthDirsFromSession(); if (!empty($authConfig['default']) && empty($authConfig['allow'][$dir]) && !in_array('default', $authDirs)) { - //所有目录都需要授权 + //所有目录都需要授权,且没有单独配置此目录需要密码 $allowed = false; - }else if (empty($authConfig['default']) && !empty($authConfig['allow'][$dir]) && !in_array($dir, $authDirs)) { - //只有部分目录需要授权 + }else if (!empty($authConfig['allow'][$dir]) && !in_array($dir, $authDirs)) { + //当前目录需要授权 $allowed = false; } diff --git a/themes/beauty/views/site/index.php b/themes/beauty/views/site/index.php index ad4a87d..d102378 100644 --- a/themes/beauty/views/site/index.php +++ b/themes/beauty/views/site/index.php @@ -207,7 +207,13 @@ eof; //判断是否需要加密访问的目录 $lockIcon = ''; - if (!empty($authConfig['enable']) && $authConfig['enable'] !== 'false' && !empty($authConfig['allow'][$dir['directory']])) { + if (!empty($authConfig['enable']) && $authConfig['enable'] !== 'false' + && ( + ( empty($authConfig['default']) && !empty($authConfig['allow'][$dir['directory']]) ) + || + !empty($authConfig['default']) //如果所有目录都需要密码 + ) + ) { $lockIcon = <<加密目录 eof;