From ee46ede9b9589e1924f703a0c14c77cb60dd032a Mon Sep 17 00:00:00 2001 From: sinne10 Date: Mon, 15 Apr 2024 21:04:20 +0200 Subject: [PATCH] Bugfix --- .../loginAndRegistration/AddUser.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/webapp/src/components/loginAndRegistration/AddUser.js b/webapp/src/components/loginAndRegistration/AddUser.js index 5b577edf..0714bd67 100644 --- a/webapp/src/components/loginAndRegistration/AddUser.js +++ b/webapp/src/components/loginAndRegistration/AddUser.js @@ -16,7 +16,7 @@ const AddUser = () => { const [password, setPassword] = useState(''); const [repeatPassword, setRepeatPassword] = useState(''); const [passwordStrength, setPasswordStrength] = useState(undefined); - const [passwordStrengthText, setPasswordStrengthText] = useState(""); + const [passwordStrengthText, setPasswordStrengthText] = useState(''); const [submitError, setSubmitError] = useState(''); @@ -27,19 +27,19 @@ const AddUser = () => { //TODO: email validation if(password !== repeatPassword){ //User put the same password - setSubmitError(t("addUser.error_passwords_no_match")); + setSubmitError("addUser.error_passwords_no_match"); } else if(/\s/.test(password)){ //User put spaces in password - setSubmitError(t("addUser.error_password_spaces")); + setSubmitError("addUser.error_password_spaces"); } else if(password.length < 8){ //Password too short - setSubmitError(t("addUser.error_password_minimum_length")); + setSubmitError("addUser.error_password_minimum_length"); } else if(password.length > 64){ //Password too long - setSubmitError(t("addUser.error_password_maximum_length")); + setSubmitError("addUser.error_password_maximum_length"); } else if(/\s/.test(username)){ //Spaces in username - setSubmitError(t("addUser.error_username_spaces")); + setSubmitError("addUser.error_username_spaces"); } else{ //Continue setSubmitError(''); @@ -50,7 +50,7 @@ const AddUser = () => { } catch (error) { if(error.response.data.error === "Username already in use"){ //TODO: Improve - setSubmitError(t("addUser.error_username_in_use")); + setSubmitError("addUser.error_username_in_use"); } console.error('Error adding user:', error); } @@ -75,22 +75,22 @@ const AddUser = () => { switch(newStrength.score){ case 0: - setPasswordStrengthText(t("addUser.very_weak_password")); + setPasswordStrengthText("addUser.very_weak_password"); break; case 1: - setPasswordStrengthText(t("addUser.very_weak_password")); + setPasswordStrengthText("addUser.very_weak_password"); break; case 2: - setPasswordStrengthText(t("addUser.weak_password")); + setPasswordStrengthText("addUser.weak_password"); break; case 3: - setPasswordStrengthText(t("addUser.good_password")); + setPasswordStrengthText("addUser.good_password"); break; case 4: - setPasswordStrengthText(t("addUser.strong_password")); + setPasswordStrengthText("addUser.strong_password"); break; default: - setPasswordStrengthText(t("addUser.very_weak_password")); + setPasswordStrengthText("addUser.very_weak_password"); break; } setPasswordStrength(newStrength); @@ -126,7 +126,7 @@ const AddUser = () => {
- {passwordStrengthText} + {t(passwordStrengthText.toString())} { onChange={(e) => setRepeatPassword(e.target.value)} />
- {submitError &&

{submitError}

} + {submitError &&

{t(submitError)}

}