mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
fix(auth): enforce max pass length at update
This commit is contained in:
@@ -96,6 +96,20 @@ describe('PUT /user/auth/update-password', async () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns an error when newPassword is too long', async () => {
|
||||||
|
const body = {
|
||||||
|
password,
|
||||||
|
newPassword: '12345678910111213141516171819202122232425262728293031323334353637383940',
|
||||||
|
confirmPassword: '12345678910111213141516171819202122232425262728293031323334353637383940',
|
||||||
|
};
|
||||||
|
|
||||||
|
await expect(user.put(ENDPOINT, body)).to.eventually.be.rejected.and.eql({
|
||||||
|
code: 400,
|
||||||
|
error: 'BadRequest',
|
||||||
|
message: t('invalidReqParams'),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('returns an error when confirmPassword is missing', async () => {
|
it('returns an error when confirmPassword is missing', async () => {
|
||||||
const body = {
|
const body = {
|
||||||
password,
|
password,
|
||||||
|
|||||||
@@ -289,8 +289,11 @@ api.updatePassword = {
|
|||||||
newPassword: {
|
newPassword: {
|
||||||
notEmpty: { errorMessage: res.t('missingNewPassword') },
|
notEmpty: { errorMessage: res.t('missingNewPassword') },
|
||||||
isLength: {
|
isLength: {
|
||||||
options: { min: common.constants.MINIMUM_PASSWORD_LENGTH },
|
options: {
|
||||||
errorMessage: res.t('minPasswordLength'),
|
min: common.constants.MINIMUM_PASSWORD_LENGTH,
|
||||||
|
max: common.constants.MAXIMUM_PASSWORD_LENGTH,
|
||||||
|
},
|
||||||
|
errorMessage: res.t('passwordIssueLength'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
confirmPassword: {
|
confirmPassword: {
|
||||||
|
|||||||
Reference in New Issue
Block a user