From 2ed79fb5dd5a91568b9b6283cae5e2ae46a3c455 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Thu, 26 Jan 2023 00:13:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E6=97=B6=E6=B2=A1=E6=9C=89=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=95=BF=E5=BA=A6=E9=99=90=E5=88=B6=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加限制,邮箱和密码最长40字符 --- client/shared/i18n/langs/en-US/translation.json | 2 ++ client/shared/i18n/langs/zh-CN/translation.json | 2 ++ .../src/components/modals/ClaimTemporaryUser.tsx | 6 ++++-- client/web/src/routes/Entry/RegisterView.tsx | 2 ++ server/services/core/user/user.service.ts | 16 ++++++++-------- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/client/shared/i18n/langs/en-US/translation.json b/client/shared/i18n/langs/en-US/translation.json index 5a0a13e6..efe5c228 100644 --- a/client/shared/i18n/langs/en-US/translation.json +++ b/client/shared/i18n/langs/en-US/translation.json @@ -145,6 +145,7 @@ "k7173d09e": "Account", "k736edc2f": "Old and new passwords do not match", "k73d9fc70": "Allow members to view admin channels", + "k7431ccfa": "The password is limited to 40 characters at most", "k7437914b": "Panel Group", "k744ee9a": "Create Group", "k74aef1ad": "Members", @@ -194,6 +195,7 @@ "k9d901c20": "Meeting room", "k9dfa2c97": "never expires", "k9f3089ce": "Create", + "k9f7d7de": "Email address is limited to 40 characters", "k9fa72780": "Conversation with {{name}}", "k9fc409ec": "Install Succeed", "ka01a00eb": "System language", diff --git a/client/shared/i18n/langs/zh-CN/translation.json b/client/shared/i18n/langs/zh-CN/translation.json index 06fcabc2..ed331430 100644 --- a/client/shared/i18n/langs/zh-CN/translation.json +++ b/client/shared/i18n/langs/zh-CN/translation.json @@ -145,6 +145,7 @@ "k7173d09e": "账户信息", "k736edc2f": "新旧密码不匹配", "k73d9fc70": "允许成员查看管理频道", + "k7431ccfa": "密码最长限制40个字符", "k7437914b": "面板分组", "k744ee9a": "创建群组", "k74aef1ad": "成员", @@ -194,6 +195,7 @@ "k9d901c20": "会议室", "k9dfa2c97": "永不过期", "k9f3089ce": "创建", + "k9f7d7de": "邮箱最长限制40个字符", "k9fa72780": "与 {{name}} 的会话", "k9fc409ec": "安装成功", "ka01a00eb": "系统语言", diff --git a/client/web/src/components/modals/ClaimTemporaryUser.tsx b/client/web/src/components/modals/ClaimTemporaryUser.tsx index 308568b0..1fcbc943 100644 --- a/client/web/src/components/modals/ClaimTemporaryUser.tsx +++ b/client/web/src/components/modals/ClaimTemporaryUser.tsx @@ -90,12 +90,14 @@ const getFields = (): MetaFormFieldMeta[] => const schema = createMetaFormSchema({ email: metaFormFieldSchema .string() + .required(t('邮箱不能为空')) .email(t('邮箱格式不正确')) - .required(t('邮箱不能为空')), + .max(40, t('邮箱最长限制40个字符')), password: metaFormFieldSchema .string() + .required(t('密码不能为空')) .min(6, t('密码不能低于6位')) - .required(t('密码不能为空')), + .max(40, t('密码最长限制40个字符')), emailOTP: metaFormFieldSchema.string().length(6, t('校验码为6位')), }); diff --git a/client/web/src/routes/Entry/RegisterView.tsx b/client/web/src/routes/Entry/RegisterView.tsx index 69297b24..5006137c 100644 --- a/client/web/src/routes/Entry/RegisterView.tsx +++ b/client/web/src/routes/Entry/RegisterView.tsx @@ -35,11 +35,13 @@ export const RegisterView: React.FC = React.memo(() => { await string() .email(t('邮箱格式不正确')) .required(t('邮箱不能为空')) + .max(40, t('邮箱最长限制40个字符')) .validate(email); await string() .min(6, t('密码不能低于6位')) .required(t('密码不能为空')) + .max(40, t('密码最长限制40个字符')) .validate(password); const data = await registerWithEmail(email, password, emailOTP); diff --git a/server/services/core/user/user.service.ts b/server/services/core/user/user.service.ts index 18f096d7..01d62e3a 100644 --- a/server/services/core/user/user.service.ts +++ b/server/services/core/user/user.service.ts @@ -79,10 +79,10 @@ class UserService extends TcService { this.registerAction('register', this.register, { rest: 'POST /register', params: { - username: [{ type: 'string', optional: true }], - email: [{ type: 'email', optional: true }], - password: 'string', - emailOTP: [{ type: 'string', optional: true }], + username: { type: 'string', optional: true, max: 40 }, + email: { type: 'email', optional: true, max: 40 }, + password: { type: 'string', max: 40 }, + emailOTP: { type: 'string', optional: true }, }, }); this.registerAction('modifyPassword', this.modifyPassword, { @@ -100,10 +100,10 @@ class UserService extends TcService { this.registerAction('claimTemporaryUser', this.claimTemporaryUser, { params: { userId: 'string', - username: [{ type: 'string', optional: true }], - email: 'email', - password: 'string', - emailOTP: [{ type: 'string', optional: true }], + username: { type: 'string', optional: true, max: 40 }, + email: { type: 'email', max: 40 }, + password: { type: 'string', max: 40 }, + emailOTP: { type: 'string', optional: true }, }, }); this.registerAction('forgetPassword', this.forgetPassword, {