mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
* Revert "Revert "Minimum password length + Static Pages fixes (#11474)""
This reverts commit d1afbf4b92.
* add min length for reset password
This commit is contained in:
@@ -245,6 +245,10 @@ api.updatePassword = {
|
||||
},
|
||||
newPassword: {
|
||||
notEmpty: { errorMessage: res.t('missingNewPassword') },
|
||||
isLength: {
|
||||
options: { min: common.constants.MINIMUM_PASSWORD_LENGTH },
|
||||
errorMessage: res.t('minPasswordLength'),
|
||||
},
|
||||
},
|
||||
confirmPassword: {
|
||||
notEmpty: { errorMessage: res.t('missingNewPassword') },
|
||||
@@ -387,13 +391,23 @@ api.resetPasswordSetNewOne = {
|
||||
|
||||
if (!isValidCode) throw new NotAuthorized(res.t('invalidPasswordResetCode'));
|
||||
|
||||
req.checkBody('newPassword', res.t('missingNewPassword')).notEmpty();
|
||||
req.checkBody('confirmPassword', res.t('missingNewPassword')).notEmpty();
|
||||
req.checkBody({
|
||||
newPassword: {
|
||||
notEmpty: { errorMessage: res.t('missingNewPassword') },
|
||||
isLength: {
|
||||
options: { min: common.constants.MINIMUM_PASSWORD_LENGTH },
|
||||
errorMessage: res.t('minPasswordLength'),
|
||||
},
|
||||
},
|
||||
confirmPassword: {
|
||||
notEmpty: { errorMessage: res.t('missingNewPassword') },
|
||||
},
|
||||
});
|
||||
|
||||
const validationErrors = req.validationErrors();
|
||||
if (validationErrors) throw validationErrors;
|
||||
|
||||
const { newPassword } = req.body;
|
||||
const { confirmPassword } = req.body;
|
||||
const { newPassword, confirmPassword } = req.body;
|
||||
|
||||
if (newPassword !== confirmPassword) {
|
||||
throw new BadRequest(res.t('passwordConfirmationMatch'));
|
||||
|
||||
Reference in New Issue
Block a user