From f883dd9c1d990752fe186a46a344e4c4de3c01b4 Mon Sep 17 00:00:00 2001 From: Zeng1998 <1129142694@qq.com> Date: Mon, 28 Nov 2022 19:32:53 +0800 Subject: [PATCH] feat: create user repeat password (#614) * feat: create user repeat password * update --- web/src/components/Settings/MemberSection.tsx | 24 ++++++++++++++++++- web/src/locales/en.json | 3 +++ web/src/locales/fr.json | 3 +++ web/src/locales/vi.json | 3 +++ web/src/locales/zh.json | 3 +++ 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/web/src/components/Settings/MemberSection.tsx b/web/src/components/Settings/MemberSection.tsx index 47e53071..38b5d1e9 100644 --- a/web/src/components/Settings/MemberSection.tsx +++ b/web/src/components/Settings/MemberSection.tsx @@ -11,6 +11,7 @@ import "../../less/settings/member-section.less"; interface State { createUserUsername: string; createUserPassword: string; + repeatUserPassword: string; } const PreferencesSection = () => { @@ -19,6 +20,7 @@ const PreferencesSection = () => { const [state, setState] = useState({ createUserUsername: "", createUserPassword: "", + repeatUserPassword: "", }); const [userList, setUserList] = useState([]); @@ -45,11 +47,22 @@ const PreferencesSection = () => { }); }; + const handleRepeatPasswordInputChange = (event: React.ChangeEvent) => { + setState({ + ...state, + repeatUserPassword: event.target.value, + }); + }; + const handleCreateUserBtnClick = async () => { if (state.createUserUsername === "" || state.createUserPassword === "") { toastHelper.error(t("message.fill-form")); return; } + if (state.createUserPassword !== state.repeatUserPassword) { + toastHelper.error(t("message.password-not-match")); + return; + } const userCreate: UserCreate = { username: state.createUserUsername, @@ -60,13 +73,13 @@ const PreferencesSection = () => { try { await api.createUser(userCreate); } catch (error: any) { - console.error(error); toastHelper.error(error.response.data.message); } await fetchUserList(); setState({ createUserUsername: "", createUserPassword: "", + repeatUserPassword: "", }); }; @@ -119,6 +132,15 @@ const PreferencesSection = () => { {t("common.password")} +
+ {t("common.repeat-password-short")} + +
diff --git a/web/src/locales/en.json b/web/src/locales/en.json index 4dbf1052..3f71959b 100644 --- a/web/src/locales/en.json +++ b/web/src/locales/en.json @@ -3,6 +3,8 @@ "about": "About", "email": "Email", "password": "Password", + "repeat-password-short": "Repeat", + "repeat-password": "Repeat the password", "new-password": "New password", "repeat-new-password": "Repeat the new password", "username": "Username", @@ -181,6 +183,7 @@ "change-memo-created-time": "Change memo created time", "memo-not-found": "Memo not found.", "fill-all": "Please fill in all fields.", + "password-not-match": "Passwords do not match.", "new-password-not-match": "New passwords do not match.", "image-load-failed": "Image load failed", "fill-form": "Please fill out this form", diff --git a/web/src/locales/fr.json b/web/src/locales/fr.json index 2680a623..250d816d 100644 --- a/web/src/locales/fr.json +++ b/web/src/locales/fr.json @@ -3,6 +3,8 @@ "about": "À propos", "email": "Email", "password": "Mot de passe", + "repeat-password-short": "Repeat", + "repeat-password": "Repeat the password", "new-password": "Nouveau mot de passe", "repeat-new-password": "Répétez le nouveau mot de passe", "username": "Nom d'utilisateur", @@ -182,6 +184,7 @@ "login-failed": "Connexion échouée", "signup-failed": "L'inscription a échoué", "user-not-found": "Utilisateur introuvable", + "password-not-match": "Passwords do not match.", "password-changed": "Mot de passe modifié", "private-only": "Ce mémo est uniquement privé.", "copied": "Copié", diff --git a/web/src/locales/vi.json b/web/src/locales/vi.json index 32189536..7f495ea0 100644 --- a/web/src/locales/vi.json +++ b/web/src/locales/vi.json @@ -3,6 +3,8 @@ "about": "Thông Tin", "email": "Email", "password": "Mật khẩu", + "repeat-password-short": "Repeat", + "repeat-password": "Repeat the password", "new-password": "Mật khẩu mới", "repeat-new-password": "Nhập lại mật khẩu mới", "username": "Tên đăng nhập", @@ -181,6 +183,7 @@ "login-failed": "Đăng nhập thất bại", "signup-failed": "Đăng ký thất bại", "user-not-found": "Không tìm thấy người dùng này", + "password-not-match": "Passwords do not match.", "password-changed": "Mật khẩu đã được thay đổi", "private-only": "Memo này có trạng thái riêng tư.", "copied": "Đã sao chép", diff --git a/web/src/locales/zh.json b/web/src/locales/zh.json index a8e468ef..9294c641 100644 --- a/web/src/locales/zh.json +++ b/web/src/locales/zh.json @@ -3,6 +3,8 @@ "about": "关于", "email": "邮箱", "password": "密码", + "repeat-password-short": "重复密码", + "repeat-password": "重复密码", "new-password": "新密码", "repeat-new-password": "重复新密码", "username": "用户名", @@ -181,6 +183,7 @@ "change-memo-created-time": "更改 Memo 创建时间", "memo-not-found": "找不到 Memo。", "fill-all": "请填写所有字段。", + "password-not-match": "密码不一致。", "new-password-not-match": "新密码不匹配。", "image-load-failed": "图片加载失败", "fill-form": "请填写此表单",