From 12acaf491c88143a435d642ced8cc8af4e1f39c2 Mon Sep 17 00:00:00 2001 From: dreamer6680 <1468683855@qq.com> Date: Tue, 13 May 2025 18:20:11 +0800 Subject: [PATCH] change password rule (#4804) * change password rule * change password.tset.ts --- packages/global/common/string/password.ts | 2 +- packages/web/i18n/en/account_info.json | 2 +- packages/web/i18n/en/common.json | 6 +++--- packages/web/i18n/en/login.json | 2 +- packages/web/i18n/zh-CN/account_info.json | 2 +- packages/web/i18n/zh-CN/common.json | 6 +++--- packages/web/i18n/zh-CN/login.json | 2 +- packages/web/i18n/zh-Hant/account_info.json | 2 +- packages/web/i18n/zh-Hant/common.json | 6 +++--- packages/web/i18n/zh-Hant/login.json | 2 +- .../global/common/string/password.test.ts | 18 +++++++++--------- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/packages/global/common/string/password.ts b/packages/global/common/string/password.ts index 4d4d85bb6..68b92d544 100644 --- a/packages/global/common/string/password.ts +++ b/packages/global/common/string/password.ts @@ -5,7 +5,7 @@ export const checkPasswordRule = (password: string) => { /[A-Z]/, // Contains uppercase letters /[!@#$%^&*()_+=-]/ // Contains special characters ]; - const validChars = /^[\dA-Za-z!@#$%^&*()_+=-]{6,100}$/; + const validChars = /^[\dA-Za-z!@#$%^&*()_+=-]{8,100}$/; // Check length and valid characters if (!validChars.test(password)) return false; diff --git a/packages/web/i18n/en/account_info.json b/packages/web/i18n/en/account_info.json index df8964dd0..9bf43d09e 100644 --- a/packages/web/i18n/en/account_info.json +++ b/packages/web/i18n/en/account_info.json @@ -47,7 +47,7 @@ "package_usage_rules": "Package usage rules: The system will give priority to using more advanced packages, and the original unused packages will take effect later.", "password": "Password", "password_mismatch": "Password Inconsistency: Two passwords are inconsistent", - "password_tip": "Password must be at least 6 characters long and contain at least two combinations: numbers, letters, or special characters", + "password_tip": "Password must be at least 8 characters long and contain at least two combinations: numbers, letters, or special characters", "password_update_error": "Exception when changing password", "password_update_success": "Password changed successfully", "pending_usage": "To be used", diff --git a/packages/web/i18n/en/common.json b/packages/web/i18n/en/common.json index 1f7d2e170..140ffe8d3 100644 --- a/packages/web/i18n/en/common.json +++ b/packages/web/i18n/en/common.json @@ -1,7 +1,6 @@ { "Action": "Action", "Add": "Add", - "add_success": "Added Successfully", "Add_new_input": "Add new input", "All": "All", "App": "Application", @@ -64,7 +63,6 @@ "Parse": "Analysis", "Permission": "Permission", "Permission_tip": "Individual permissions are greater than group permissions", - "please_input_name": "Please Enter a Name", "Preview": "Preview", "Remove": "Remove", "Rename": "Rename", @@ -94,6 +92,7 @@ "action_confirm": "Confirm", "add_new": "add_new", "add_new_param": "Add new param", + "add_success": "Added Successfully", "all_quotes": "All quotes", "all_result": "Full Results", "app_not_version": "This application has not been published, please publish it first", @@ -962,6 +961,7 @@ "permission.manager": "administrator", "permission.read": "Read permission", "permission.write": "write permission", + "please_input_name": "Please Enter a Name", "plugin.App": "Select App", "plugin.Currentapp": "Current App", "plugin.Description": "Description", @@ -1260,7 +1260,7 @@ "user.no_usage_records": "No Usage Records", "user.old_password": "Old Password", "user.password_message": "Password must be at least 4 characters and at most 60 characters", - "user.password_tip": "Password must be at least 6 characters long and contain at least two combinations: numbers, letters, or special characters", + "user.password_tip": "Password must be at least 8 characters long and contain at least two combinations: numbers, letters, or special characters", "user.reset_password": "Reset Password", "user.reset_password_tip": "The initial password is not set/the password has not been modified for a long time, please reset the password", "user.team.Balance": "Team Balance", diff --git a/packages/web/i18n/en/login.json b/packages/web/i18n/en/login.json index f84296894..01694516e 100644 --- a/packages/web/i18n/en/login.json +++ b/packages/web/i18n/en/login.json @@ -8,7 +8,7 @@ "login_success": "Login successful", "no_remind": "Don't remind again", "password_condition": "Password maximum 60 characters", - "password_tip": "Password must be at least 6 characters long and contain at least two combinations: numbers, letters, or special characters", + "password_tip": "Password must be at least 8 characters long and contain at least two combinations: numbers, letters, or special characters", "policy_tip": "By using this service, you agree to our", "privacy": "Privacy Policy", "privacy_policy": "Privacy Policy", diff --git a/packages/web/i18n/zh-CN/account_info.json b/packages/web/i18n/zh-CN/account_info.json index 2599f5148..e923c1e61 100644 --- a/packages/web/i18n/zh-CN/account_info.json +++ b/packages/web/i18n/zh-CN/account_info.json @@ -45,7 +45,7 @@ "package_usage_rules": "套餐使用规则:系统优先使用更高级的套餐,原未用完的套餐将延后生效", "password": "密码", "password_mismatch": "密码不一致: 两次密码不一致", - "password_tip": "密码至少 6 位,且至少包含两种组合:数字、字母或特殊字符", + "password_tip": "密码至少 8 位,且至少包含两种组合:数字、字母或特殊字符", "password_update_error": "修改密码异常", "password_update_success": "修改密码成功", "pending_usage": "待使用", diff --git a/packages/web/i18n/zh-CN/common.json b/packages/web/i18n/zh-CN/common.json index ad81e6d26..9d02b4b81 100644 --- a/packages/web/i18n/zh-CN/common.json +++ b/packages/web/i18n/zh-CN/common.json @@ -1,7 +1,6 @@ { "Action": "操作", "Add": "添加", - "add_success": "添加成功", "Add_new_input": "新增输入", "All": "全部", "App": "应用", @@ -64,7 +63,6 @@ "Parse": "解析", "Permission": "权限", "Permission_tip": "个人权限大于群组权限", - "please_input_name": "请输入名称", "Preview": "预览", "Remove": "移除", "Rename": "重命名", @@ -94,6 +92,7 @@ "action_confirm": "操作确认", "add_new": "新增", "add_new_param": "新增参数", + "add_success": "添加成功", "all_quotes": "全部引用", "all_result": "完整结果", "app_not_version": " 该应用未发布过,请先发布应用", @@ -961,6 +960,7 @@ "permission.manager": "管理员", "permission.read": "读权限", "permission.write": "写权限", + "please_input_name": "请输入名称", "plugin.App": "选择应用", "plugin.Currentapp": "当前应用", "plugin.Description": "描述", @@ -1259,7 +1259,7 @@ "user.no_usage_records": "暂无使用记录", "user.old_password": "旧密码", "user.password_message": "密码最少 4 位最多 60 位", - "user.password_tip": "密码至少 6 位,且至少包含两种组合:数字、字母或特殊字符", + "user.password_tip": "密码至少 8 位,且至少包含两种组合:数字、字母或特殊字符", "user.reset_password": "重置密码", "user.reset_password_tip": "未设置初始密码/长时间未修改密码,请重置密码", "user.team.Balance": "团队余额", diff --git a/packages/web/i18n/zh-CN/login.json b/packages/web/i18n/zh-CN/login.json index f3cc74a89..51816a916 100644 --- a/packages/web/i18n/zh-CN/login.json +++ b/packages/web/i18n/zh-CN/login.json @@ -8,7 +8,7 @@ "login_success": "登录成功", "no_remind": "不再提醒", "password_condition": "密码最多 60 位", - "password_tip": "密码至少 6 位,且至少包含两种组合:数字、字母或特殊字符", + "password_tip": "密码至少 8 位,且至少包含两种组合:数字、字母或特殊字符", "policy_tip": "使用即代表你同意我们的", "privacy": "隐私协议", "privacy_policy": "隐私政策", diff --git a/packages/web/i18n/zh-Hant/account_info.json b/packages/web/i18n/zh-Hant/account_info.json index 888738359..20cf1f792 100644 --- a/packages/web/i18n/zh-Hant/account_info.json +++ b/packages/web/i18n/zh-Hant/account_info.json @@ -47,7 +47,7 @@ "package_usage_rules": "套餐使用規則:系統優先使用更進階的套餐,原未用完的套餐將延遲生效", "password": "密碼", "password_mismatch": "密碼不一致:兩次密碼不一致", - "password_tip": "密碼至少 6 位,且至少包含兩種組合:數字、字母或特殊字元", + "password_tip": "密碼至少 8 位,且至少包含兩種組合:數字、字母或特殊字元", "password_update_error": "修改密碼異常", "password_update_success": "修改密碼成功", "pending_usage": "待使用", diff --git a/packages/web/i18n/zh-Hant/common.json b/packages/web/i18n/zh-Hant/common.json index 993406574..b2ad761be 100644 --- a/packages/web/i18n/zh-Hant/common.json +++ b/packages/web/i18n/zh-Hant/common.json @@ -1,7 +1,6 @@ { "Action": "操作", "Add": "新增", - "add_success": "新增成功", "Add_new_input": "新增輸入", "All": "全部", "App": "應用程式", @@ -64,7 +63,6 @@ "Parse": "解析", "Permission": "權限", "Permission_tip": "個人權限大於群組權限", - "please_input_name": "請輸入名稱", "Preview": "預覽", "Remove": "移除", "Rename": "重新命名", @@ -94,6 +92,7 @@ "action_confirm": "確認", "add_new": "新增", "add_new_param": "新增參數", + "add_success": "新增成功", "all_quotes": "全部引用", "all_result": "完整結果", "app_not_version": "該應用未發布過,請先發布應用", @@ -961,6 +960,7 @@ "permission.manager": "管理員", "permission.read": "讀取權限", "permission.write": "寫入權限", + "please_input_name": "請輸入名稱", "plugin.App": "選擇應用程式", "plugin.Currentapp": "目前應用程式", "plugin.Description": "描述", @@ -1259,7 +1259,7 @@ "user.no_usage_records": "無使用紀錄", "user.old_password": "舊密碼", "user.password_message": "密碼最少 4 位最多 60 位", - "user.password_tip": "密碼至少 6 位,且至少包含兩種組合:數字、字母或特殊字元", + "user.password_tip": "密碼至少 8 位,且至少包含兩種組合:數字、字母或特殊字元", "user.reset_password": "重置密碼", "user.reset_password_tip": "未設置初始密碼/長時間未修改密碼,請重置密碼", "user.team.Balance": "團隊餘額", diff --git a/packages/web/i18n/zh-Hant/login.json b/packages/web/i18n/zh-Hant/login.json index 5ef07522f..8321b62f9 100644 --- a/packages/web/i18n/zh-Hant/login.json +++ b/packages/web/i18n/zh-Hant/login.json @@ -8,7 +8,7 @@ "login_success": "登入成功", "no_remind": "不再提醒", "password_condition": "密碼最多 60 個字元", - "password_tip": "密碼至少 6 位,且至少包含兩種組合:數字、字母或特殊字元", + "password_tip": "密碼至少 8 位,且至少包含兩種組合:數字、字母或特殊字元", "policy_tip": "使用即代表您同意我們的", "privacy": "隱私權政策", "privacy_policy": "隱私權政策", diff --git a/test/cases/function/packages/global/common/string/password.test.ts b/test/cases/function/packages/global/common/string/password.test.ts index 3c84913ec..c3aa7b937 100644 --- a/test/cases/function/packages/global/common/string/password.test.ts +++ b/test/cases/function/packages/global/common/string/password.test.ts @@ -4,8 +4,8 @@ import { checkPasswordRule } from '@fastgpt/global/common/string/password'; describe('PasswordRule', () => { it('should be a valid password', () => { // Small password - expect(checkPasswordRule('123A')).toBe(false); - expect(checkPasswordRule('@ga21')).toBe(false); + expect(checkPasswordRule('123ABC')).toBe(false); + expect(checkPasswordRule('@ga2123')).toBe(false); // Test single type characters expect(checkPasswordRule('123456')).toBe(false); @@ -14,13 +14,13 @@ describe('PasswordRule', () => { expect(checkPasswordRule('!@#$%^')).toBe(false); // only special chars // Test two types combination - expect(checkPasswordRule('abc123')).toBe(true); // lowercase + numbers - expect(checkPasswordRule('abcABC')).toBe(true); // lowercase + uppercase - expect(checkPasswordRule('abc!@#')).toBe(true); // lowercase + special chars - expect(checkPasswordRule('ABC!@#')).toBe(true); // uppercase + special chars - expect(checkPasswordRule('ABC123')).toBe(true); // uppercase + numbers - expect(checkPasswordRule('123!@#')).toBe(true); // numbers + special chars - expect(checkPasswordRule('!@123fa')).toBe(true); // numbers + special chars + expect(checkPasswordRule('abcd1234')).toBe(true); // lowercase + numbers + expect(checkPasswordRule('abcdABCD')).toBe(true); // lowercase + uppercase + expect(checkPasswordRule('abcd!@#$')).toBe(true); // lowercase + special chars + expect(checkPasswordRule('ABCD!@#$')).toBe(true); // uppercase + special chars + expect(checkPasswordRule('ABCD1234')).toBe(true); // uppercase + numbers + expect(checkPasswordRule('1234!@#$')).toBe(true); // numbers + special chars + expect(checkPasswordRule('!@123fab')).toBe(true); // numbers + special chars expect(checkPasswordRule('+2222()222')).toBe(true); // special chars + numbers expect(checkPasswordRule('_2222()-+=22')).toBe(true); // special chars + numbers