feat: Add Parse Server option resetPasswordSuccessOnInvalidEmail to choose success or error response on password reset with invalid email (#7551)
This commit is contained in:
@@ -1082,4 +1082,43 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw on an invalid reset password', async () => {
|
||||
await reconfigureServer({
|
||||
appName: 'coolapp',
|
||||
publicServerURL: 'http://localhost:1337/1',
|
||||
emailAdapter: MockEmailAdapterWithOptions({
|
||||
fromAddress: 'parse@example.com',
|
||||
apiKey: 'k',
|
||||
domain: 'd',
|
||||
}),
|
||||
passwordPolicy: {
|
||||
resetPasswordSuccessOnInvalidEmail: false,
|
||||
},
|
||||
});
|
||||
|
||||
await expectAsync(Parse.User.requestPasswordReset('test@example.com')).toBeRejectedWith(
|
||||
new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'A user with that email does not exist.')
|
||||
);
|
||||
});
|
||||
|
||||
it('validate resetPasswordSuccessonInvalidEmail', async () => {
|
||||
const invalidValues = [[], {}, 1, 'string'];
|
||||
for (const value of invalidValues) {
|
||||
await expectAsync(
|
||||
reconfigureServer({
|
||||
appName: 'coolapp',
|
||||
publicServerURL: 'http://localhost:1337/1',
|
||||
emailAdapter: MockEmailAdapterWithOptions({
|
||||
fromAddress: 'parse@example.com',
|
||||
apiKey: 'k',
|
||||
domain: 'd',
|
||||
}),
|
||||
passwordPolicy: {
|
||||
resetPasswordSuccessOnInvalidEmail: value,
|
||||
},
|
||||
})
|
||||
).toBeRejectedWith('resetPasswordSuccessOnInvalidEmail must be a boolean value');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user