Skip to content

Commit 1e7d0da

Browse files
committed
Fix the dynamic config check
1 parent ea52a8b commit 1e7d0da

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

backend/plugin/config/sql/mysql/init.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ values
55
(3, '服务器端口', 'EMAIL', 'EMAIL_PORT', '465', false, null, now(), null),
66
(4, '邮箱账号', 'EMAIL', 'EMAIL_USERNAME', 'fba@qq.com', false, null, now(), null),
77
(5, '邮箱密码', 'EMAIL', 'EMAIL_PASSWORD', '', false, null, now(), null),
8-
(6, 'SSL 加密', 'EMAIL', 'EMAIL_SSL', '1', false, null, now(), null),
8+
(6, 'SSL 加密', 'EMAIL', 'EMAIL_SSL', 'true', false, null, now(), null),
99
(7, '状态', 'USER_SECURITY', 'USER_SECURITY_CONFIG_STATUS', '1', false, null, now(), null),
1010
(8, '密码错误锁定阈值', 'USER_SECURITY', 'USER_LOCK_THRESHOLD', '5', false, '0 表示禁用锁定', now(), null),
1111
(9, '密码错误锁定时长(秒)', 'USER_SECURITY', 'USER_LOCK_SECONDS', '300', false, null, now(), null),
@@ -14,6 +14,6 @@ values
1414
(12, '密码历史检查次数', 'USER_SECURITY', 'USER_PASSWORD_HISTORY_CHECK_COUNT', '3', false, null, now(), null),
1515
(13, '密码最小长度', 'USER_SECURITY', 'USER_PASSWORD_MIN_LENGTH', '6', false, null, now(), null),
1616
(14, '密码最大长度', 'USER_SECURITY', 'USER_PASSWORD_MAX_LENGTH', '32', false, null, now(), null),
17-
(15, '密码必须包含特殊字符', 'USER_SECURITY', 'USER_PASSWORD_REQUIRE_SPECIAL_CHAR', '0', false, null, now(), null),
17+
(15, '密码必须包含特殊字符', 'USER_SECURITY', 'USER_PASSWORD_REQUIRE_SPECIAL_CHAR', 'false', false, null, now(), null),
1818
(16, '状态', 'LOGIN', 'LOGIN_CONFIG_STATUS', '1', false, null, now(), null),
19-
(17, '验证码开关', 'LOGIN', 'LOGIN_CAPTCHA_ENABLED', '1', false, null, now(), null);
19+
(17, '验证码开关', 'LOGIN', 'LOGIN_CAPTCHA_ENABLED', 'true', false, null, now(), null);

backend/plugin/config/sql/mysql/init_snowflake.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ values
55
(2069061886627938306, '服务器端口', 'EMAIL', 'EMAIL_PORT', '465', false, null, now(), null),
66
(2069061886627938307, '邮箱账号', 'EMAIL', 'EMAIL_USERNAME', 'fba@qq.com', false, null, now(), null),
77
(2069061886627938308, '邮箱密码', 'EMAIL', 'EMAIL_PASSWORD', '', false, null, now(), null),
8-
(2069061886627938309, 'SSL 加密', 'EMAIL', 'EMAIL_SSL', '1', false, null, now(), null),
8+
(2069061886627938309, 'SSL 加密', 'EMAIL', 'EMAIL_SSL', 'true', false, null, now(), null),
99
(2069061886627938310, '状态', 'USER_SECURITY', 'USER_SECURITY_CONFIG_STATUS', '1', false, null, now(), null),
1010
(2069061886627938311, '密码错误锁定阈值', 'USER_SECURITY', 'USER_LOCK_THRESHOLD', '5', false, '0 表示禁用锁定', now(), null),
1111
(2069061886627938312, '密码错误锁定时长(秒)', 'USER_SECURITY', 'USER_LOCK_SECONDS', '300', false, null, now(), null),
@@ -14,6 +14,6 @@ values
1414
(2069061886627938315, '密码历史检查次数', 'USER_SECURITY', 'USER_PASSWORD_HISTORY_CHECK_COUNT', '3', false, null, now(), null),
1515
(2069061886627938316, '密码最小长度', 'USER_SECURITY', 'USER_PASSWORD_MIN_LENGTH', '6', false, null, now(), null),
1616
(2069061886627938317, '密码最大长度', 'USER_SECURITY', 'USER_PASSWORD_MAX_LENGTH', '32', false, null, now(), null),
17-
(2069061886627938318, '密码必须包含特殊字符', 'USER_SECURITY', 'USER_PASSWORD_REQUIRE_SPECIAL_CHAR', '0', false, null, now(), null),
17+
(2069061886627938318, '密码必须包含特殊字符', 'USER_SECURITY', 'USER_PASSWORD_REQUIRE_SPECIAL_CHAR', 'false', false, null, now(), null),
1818
(2069061886627938319, '状态', 'LOGIN', 'LOGIN_CONFIG_STATUS', '1', false, null, now(), null),
19-
(2069061886627938320, '验证码开关', 'LOGIN', 'LOGIN_CAPTCHA_ENABLED', '1', false, null, now(), null);
19+
(2069061886627938320, '验证码开关', 'LOGIN', 'LOGIN_CAPTCHA_ENABLED', 'true', false, null, now(), null);

backend/plugin/config/sql/postgresql/init.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ values
55
(3, '服务器端口', 'EMAIL', 'EMAIL_PORT', '465', false, null, now(), null),
66
(4, '邮箱账号', 'EMAIL', 'EMAIL_USERNAME', 'fba@qq.com', false, null, now(), null),
77
(5, '邮箱密码', 'EMAIL', 'EMAIL_PASSWORD', '', false, null, now(), null),
8-
(6, 'SSL 加密', 'EMAIL', 'EMAIL_SSL', '1', false, null, now(), null),
8+
(6, 'SSL 加密', 'EMAIL', 'EMAIL_SSL', 'true', false, null, now(), null),
99
(7, '状态', 'USER_SECURITY', 'USER_SECURITY_CONFIG_STATUS', '1', false, null, now(), null),
1010
(8, '密码错误锁定阈值', 'USER_SECURITY', 'USER_LOCK_THRESHOLD', '5', false, '0 表示禁用锁定', now(), null),
1111
(9, '密码错误锁定时长(秒)', 'USER_SECURITY', 'USER_LOCK_SECONDS', '300', false, null, now(), null),
@@ -14,8 +14,8 @@ values
1414
(12, '密码历史检查次数', 'USER_SECURITY', 'USER_PASSWORD_HISTORY_CHECK_COUNT', '3', false, null, now(), null),
1515
(13, '密码最小长度', 'USER_SECURITY', 'USER_PASSWORD_MIN_LENGTH', '6', false, null, now(), null),
1616
(14, '密码最大长度', 'USER_SECURITY', 'USER_PASSWORD_MAX_LENGTH', '32', false, null, now(), null),
17-
(15, '密码必须包含特殊字符', 'USER_SECURITY', 'USER_PASSWORD_REQUIRE_SPECIAL_CHAR', '0', false, null, now(), null),
17+
(15, '密码必须包含特殊字符', 'USER_SECURITY', 'USER_PASSWORD_REQUIRE_SPECIAL_CHAR', 'false', false, null, now(), null),
1818
(16, '状态', 'LOGIN', 'LOGIN_CONFIG_STATUS', '1', false, null, now(), null),
19-
(17, '验证码开关', 'LOGIN', 'LOGIN_CAPTCHA_ENABLED', '1', false, null, now(), null);
19+
(17, '验证码开关', 'LOGIN', 'LOGIN_CAPTCHA_ENABLED', 'true', false, null, now(), null);
2020

2121
select setval(pg_get_serial_sequence('sys_config', 'id'),coalesce(max(id), 0) + 1, true) from sys_config;

backend/plugin/config/sql/postgresql/init_snowflake.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ values
55
(2069061886627938306, '服务器端口', 'EMAIL', 'EMAIL_PORT', '465', false, null, now(), null),
66
(2069061886627938307, '邮箱账号', 'EMAIL', 'EMAIL_USERNAME', 'fba@qq.com', false, null, now(), null),
77
(2069061886627938308, '邮箱密码', 'EMAIL', 'EMAIL_PASSWORD', '', false, null, now(), null),
8-
(2069061886627938309, 'SSL 加密', 'EMAIL', 'EMAIL_SSL', '1', false, null, now(), null),
8+
(2069061886627938309, 'SSL 加密', 'EMAIL', 'EMAIL_SSL', 'true', false, null, now(), null),
99
(2069061886627938310, '状态', 'USER_SECURITY', 'USER_SECURITY_CONFIG_STATUS', '1', false, null, now(), null),
1010
(2069061886627938311, '密码错误锁定阈值', 'USER_SECURITY', 'USER_LOCK_THRESHOLD', '5', false, '0 表示禁用锁定', now(), null),
1111
(2069061886627938312, '密码错误锁定时长(秒)', 'USER_SECURITY', 'USER_LOCK_SECONDS', '300', false, null, now(), null),
@@ -14,6 +14,6 @@ values
1414
(2069061886627938315, '密码历史检查次数', 'USER_SECURITY', 'USER_PASSWORD_HISTORY_CHECK_COUNT', '3', false, null, now(), null),
1515
(2069061886627938316, '密码最小长度', 'USER_SECURITY', 'USER_PASSWORD_MIN_LENGTH', '6', false, null, now(), null),
1616
(2069061886627938317, '密码最大长度', 'USER_SECURITY', 'USER_PASSWORD_MAX_LENGTH', '32', false, null, now(), null),
17-
(2069061886627938318, '密码必须包含特殊字符', 'USER_SECURITY', 'USER_PASSWORD_REQUIRE_SPECIAL_CHAR', '0', false, null, now(), null),
17+
(2069061886627938318, '密码必须包含特殊字符', 'USER_SECURITY', 'USER_PASSWORD_REQUIRE_SPECIAL_CHAR', 'false', false, null, now(), null),
1818
(2069061886627938319, '状态', 'LOGIN', 'LOGIN_CONFIG_STATUS', '1', false, null, now(), null),
19-
(2069061886627938320, '验证码开关', 'LOGIN', 'LOGIN_CAPTCHA_ENABLED', '1', false, null, now(), null);
19+
(2069061886627938320, '验证码开关', 'LOGIN', 'LOGIN_CAPTCHA_ENABLED', 'true', false, null, now(), null);

backend/utils/dynamic_config.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async def load_user_security_config(db: AsyncSession) -> None: # noqa: C901
4949
password_require_special_char_key = 'USER_PASSWORD_REQUIRE_SPECIAL_CHAR'
5050

5151
configs = {dc['key']: dc['value'] for dc in select_list_serialize(dynamic_config)}
52-
if configs.get(security_config_status_key):
52+
if int(configs.get(security_config_status_key)):
5353
if lock_threshold_key in configs:
5454
settings.USER_LOCK_THRESHOLD = int(configs[lock_threshold_key])
5555
if lock_seconds_key in configs:
@@ -65,7 +65,7 @@ async def load_user_security_config(db: AsyncSession) -> None: # noqa: C901
6565
if password_max_length_key in configs:
6666
settings.USER_PASSWORD_MAX_LENGTH = int(configs[password_max_length_key])
6767
if password_require_special_char_key in configs:
68-
settings.USER_PASSWORD_REQUIRE_SPECIAL_CHAR = bool(configs[password_require_special_char_key])
68+
settings.USER_PASSWORD_REQUIRE_SPECIAL_CHAR = configs[password_require_special_char_key] == 'true'
6969

7070

7171
async def load_login_config(db: AsyncSession) -> None:
@@ -90,8 +90,8 @@ async def load_login_config(db: AsyncSession) -> None:
9090
login_captcha_enabled_key = 'LOGIN_CAPTCHA_ENABLED'
9191

9292
configs = {dc['key']: dc['value'] for dc in select_list_serialize(dynamic_config)}
93-
if configs.get(login_config_status_key) and login_captcha_enabled_key in configs:
94-
settings.LOGIN_CAPTCHA_ENABLED = bool(configs[login_captcha_enabled_key])
93+
if int(configs.get(login_config_status_key)) and login_captcha_enabled_key in configs:
94+
settings.LOGIN_CAPTCHA_ENABLED = configs[login_captcha_enabled_key] == 'true'
9595

9696

9797
async def load_email_config(db: AsyncSession) -> None:
@@ -120,12 +120,12 @@ async def load_email_config(db: AsyncSession) -> None:
120120
password_key = 'EMAIL_PASSWORD'
121121

122122
configs = {dc['key']: dc['value'] for dc in select_list_serialize(dynamic_config)}
123-
if configs.get(email_config_status_key):
123+
if int(configs.get(email_config_status_key)):
124124
settings.EMAIL_HOST = str(configs[host_key])
125125
if configs.get(port_key):
126126
settings.EMAIL_PORT = int(configs[port_key])
127127
if configs.get(ssl_key):
128-
settings.EMAIL_SSL = bool(configs[ssl_key])
128+
settings.EMAIL_SSL = configs[ssl_key] == 'true'
129129
if configs.get(username_key):
130130
settings.EMAIL_USERNAME = str(configs[username_key])
131131
if configs.get(password_key):

0 commit comments

Comments
 (0)