allow flow through to passwordPolicy in case of empty ('') password (#3560)
This commit is contained in:
committed by
Florent Vilmart
parent
41358d2226
commit
0e900cbefd
@@ -219,6 +219,28 @@ describe("Password Policy: ", () => {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('signup should fail if password is empty', (done) => {
|
||||||
|
const user = new Parse.User();
|
||||||
|
reconfigureServer({
|
||||||
|
appName: 'passwordPolicy',
|
||||||
|
passwordPolicy: {
|
||||||
|
validatorPattern: "^.{8,}" // password should contain at least 8 char
|
||||||
|
},
|
||||||
|
publicServerURL: "http://localhost:8378/1"
|
||||||
|
}).then(() => {
|
||||||
|
user.setUsername("user1");
|
||||||
|
user.setPassword("");
|
||||||
|
user.set('email', 'user1@parse.com');
|
||||||
|
user.signUp().then(() => {
|
||||||
|
fail('Should have failed as password does not conform to the policy.');
|
||||||
|
done();
|
||||||
|
}).catch((error) => {
|
||||||
|
expect(error.message).toEqual('Cannot sign up user with an empty password.');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
it('signup should succeed if password conforms to the policy enforced using validatorPattern', (done) => {
|
it('signup should succeed if password conforms to the policy enforced using validatorPattern', (done) => {
|
||||||
const user = new Parse.User();
|
const user = new Parse.User();
|
||||||
reconfigureServer({
|
reconfigureServer({
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ RestWrite.prototype.transformUser = function() {
|
|||||||
|
|
||||||
return promise.then(() => {
|
return promise.then(() => {
|
||||||
// Transform the password
|
// Transform the password
|
||||||
if (!this.data.password) {
|
if (this.data.password === undefined) { // ignore only if undefined. should proceed if empty ('')
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user