Skip to content

Commit

Permalink
fix(auth): improve invalid reset password token message
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristiaanScheermeijer committed Aug 5, 2021
1 parent f8bf93a commit 01a565e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/containers/AccountModal/forms/EditPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { object, string } from 'yup';
import { useTranslation } from 'react-i18next';

import { changePassword } from '../../../stores/AccountStore';
import { addQueryParam } from '../../../utils/history';
import useForm, { UseFormOnSubmitHandler } from '../../../hooks/useForm';
import type { EditPasswordFormData } from '../../../../types/account';
import EditPasswordForm from '../../../components/EditPasswordForm/EditPasswordForm';
import useQueryParam from '../../../hooks/useQueryParam';
import { addQueryParams } from '../../../utils/formatting';

const ResetPassword: React.FC = () => {
const { t } = useTranslation('account');
Expand All @@ -25,13 +25,13 @@ const ResetPassword: React.FC = () => {

try {
await changePassword(emailParam, formData.password, resetPasswordTokenParam);
history.push(addQueryParam(history, 'u', 'login'));
history.push(addQueryParams(window.location.origin, { u: 'login' }));
} catch (error: unknown) {
if (error instanceof Error) {
if (error.message.includes('invalid param password')) {
setErrors({ password: t('reset.invalid_password') });
} else if (error.message.includes('resetPasswordToken is not valid')) {
setErrors({ password: t('reset.invalid_token') });
setErrors({ form: t('reset.invalid_token') });
}

setValue('password', '');
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/locales/en_US/account.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
"hide_password": "Hide password",
"invalid_link": "Invalid link",
"invalid_password": "Invalid password",
"invalid_token": "Invalid link",
"invalid_token": "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 Down

0 comments on commit 01a565e

Please sign in to comment.