Archived
2

changed password policy

This commit is contained in:
VLE2FE 2020-08-07 10:54:01 +02:00
parent 4ce65ad7cc
commit 1396fb0326
2 changed files with 6 additions and 7 deletions

View File

@ -303,8 +303,8 @@ describe('/user', () => {
url: '/user', url: '/user',
auth: {basic: 'admin'}, auth: {basic: 'admin'},
httpStatus: 400, httpStatus: 400,
req: {pass: 'password'}, req: {pass: 'pass'},
res: {status: 'Invalid body format', details: 'password must have at least 8 characters, one uppercase and one lowercase character, one number and at least one of the following characters: !\"\\#%&\'()*+,-.\\/:;<=>?@[]^_`\u0000|}~'} res: {status: 'Invalid body format', details: '"pass" length must be at least 8 characters long'}
}); });
}); });
it('rejects requests from non-admins for another user', done => { it('rejects requests from non-admins for another user', done => {
@ -585,8 +585,8 @@ describe('/user', () => {
url: '/user/new', url: '/user/new',
auth: {basic: 'admin'}, auth: {basic: 'admin'},
httpStatus: 400, httpStatus: 400,
req: {email: 'john.doe@bosch.com', name: 'johndoe', pass: 'password', level: 'read', location: 'Rng', devices: ['Alpha II']}, req: {email: 'john.doe@bosch.com', name: 'johndoe', pass: 'pass', level: 'read', location: 'Rng', devices: ['Alpha II']},
res: {status: 'Invalid body format', details: 'password must have at least 8 characters, one uppercase and one lowercase character, one number and at least one of the following characters: !\"\\#%&\'()*+,-.\\/:;<=>?@[]^_`\u0000|}~'} res: {status: 'Invalid body format', details: '"pass" length must be at least 8 characters long'}
}); });
}); });
it('rejects requests from non-admins', done => { it('rejects requests from non-admins', done => {

View File

@ -17,9 +17,8 @@ export default class UserValidate { // validate input for user
.max(128), .max(128),
pass: Joi.string() pass: Joi.string()
.pattern(/^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[!"#%&'()*+,-.\/:;<=>?@[\]^_`{|}~])(?=\S+$)[a-zA-Z0-9!"#%&'()*+,\-.\/:;<=>?@[\]^_`{|}~]{8,}$/) .min(8)
.max(128) .max(128),
.messages({'string.pattern.base': 'password must have at least 8 characters, one uppercase and one lowercase character, one number and at least one of the following characters: !"\\#%&\'()*+,-.\\/:;<=>?@[]^_`\\{|}~'}),
level: Joi.string() level: Joi.string()
.valid(...globals.levels), .valid(...globals.levels),