Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(user): password strength on reset #395

Merged
merged 5 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion public/locales/en/account.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@
"forgot_password": "Forgot password",
"forgot_text": "We will send you an email with instructions on how to reset your password.",
"hide_password": "Hide password",
"invalid_token": "Invalid token. Check if you've entered the correct token that we emailed you or request a new one by restarting the forgot password process.",
"invalid_link": "Invalid link",
"invalid_password": "Invalid password",
"invalid_token": "The reset password link is invalid or has expired. Please try resetting your password again.",
"invalid_reset_link": "The reset password link is invalid or has expired. Please try resetting your password again.",
"link_sent": "Password link sent",
"link_sent_text": "Please check your inbox at {{email}}",
"new_password": "New password",
Expand All @@ -189,6 +190,7 @@
"repeat_new_password": "Repeat new password",
"reset_password": "Edit Password",
"reset_password_token": "Token",
"password_strength": "Although your password meets the criteria for a strong password, it includes elements that are not advisable, such as prohibited phrases or repeated words. Please modify it to ensure account safety.",
"text": "If you want to edit your password, click 'YES, Reset' to receive password reset instruction on your mail",
"try_again": "Try again",
"view_password": "View password",
Expand Down
4 changes: 3 additions & 1 deletion public/locales/es/account.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,10 @@
"forgot_password": "¿Olvidaste tu contraseña?",
"forgot_text": "Te enviaremos un correo electrónico con instrucciones sobre cómo restablecer tu contraseña.",
"hide_password": "Ocultar contraseña",
"invalid_token": "Token no válido. Verifica si has ingresado el token correcto que te enviamos por correo electrónico o solicita uno nuevo reiniciando el proceso de restablecimiento de contraseña.",
"invalid_link": "Enlace no válido",
"invalid_password": "Contraseña no válida",
"invalid_token": "El enlace de restablecimiento de contraseña no es válido o ha expirado. Por favor, intenta restablecer tu contraseña nuevamente.",
"invalid_reset_link": "El enlace de restablecimiento de contraseña no es válido o ha expirado. Por favor, intenta restablecer tu contraseña nuevamente.",
"link_sent": "Enlace de contraseña enviado",
"link_sent_text": "Por favor, revisa tu bandeja de entrada en {{email}}",
"new_password": "Nueva contraseña",
Expand All @@ -199,6 +200,7 @@
"repeat_new_password": "Repetir nueva contraseña",
"reset_password": "Editar contraseña",
"reset_password_token": "Token",
"password_strength": "Aunque tu contraseña cumple con los criterios de una contraseña segura, incluye elementos que no son recomendables, como frases prohibidas o palabras repetidas. Por favor, modifícala para garantizar la seguridad de tu cuenta.",
"text": "Si deseas editar tu contraseña, haz clic en 'SÍ, Restablecer' para recibir instrucciones de restablecimiento de contraseña en tu correo electrónico",
"try_again": "Intentar nuevamente",
"view_password": "Ver contraseña",
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditPasswordForm/EditPasswordForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const EditPasswordForm: React.FC<Props> = ({ onSubmit, onChange, onBlur, showOld
) : showResetTokenField ? (
<TextField
className={styles.textField}
value={value.resetPasswordToken}
value={value.resetPasswordToken || ''}
onChange={onChange}
onBlur={onBlur}
label={t('reset.reset_password_token')}
Expand Down
4 changes: 4 additions & 0 deletions src/containers/AccountModal/forms/EditPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ const ResetPassword: React.FC = () => {
if (error.message.includes('invalid param password')) {
setErrors({ password: t('reset.invalid_password') });
} else if (error.message.includes('resetPasswordToken is not valid')) {
setErrors({ form: t('reset.invalid_reset_link') });
} else if (error.message.includes('score does not match standards')) {
setErrors({ form: t('reset.password_strength') });
} else if (error.message.includes('password could not be set')) {
setErrors({ form: t('reset.invalid_token') });
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/services/inplayer.account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,9 @@ export const changePasswordWithOldPassword: ChangePasswordWithOldPassword = asyn
errors: [],
responseData: {},
};
} catch {
throw new Error('Failed to change password.');
} catch (error: unknown) {
const { response } = error as InPlayerError;
throw new Error(response.data.message);
kiremitrov123 marked this conversation as resolved.
Show resolved Hide resolved
}
};

Expand All @@ -257,8 +258,9 @@ export const changePasswordWithResetToken: ChangePassword = async (payload) => {
errors: [],
responseData: {},
};
} catch {
throw new Error('Failed to change password.');
} catch (error: unknown) {
const { response } = error as InPlayerError;
throw new Error(response.data.message);
}
};

Expand Down