Skip to content

Commit 2124488

Browse files
committed
new: reset password improve transparency
1 parent 0081e1c commit 2124488

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

spec/ValidationAndPasswordsReset.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,4 +1082,22 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
10821082
done();
10831083
});
10841084
});
1085+
1086+
it('should throw on an invalid reset password', async () => {
1087+
await reconfigureServer({
1088+
appName: 'coolapp',
1089+
publicServerURL: 'http://localhost:1337/1',
1090+
emailAdapter: MockEmailAdapterWithOptions({
1091+
fromAddress: '[email protected]',
1092+
apiKey: 'k',
1093+
domain: 'd',
1094+
}),
1095+
});
1096+
await expectAsync(Parse.User.requestPasswordReset('[email protected]')).toBeRejectedWith(
1097+
new Parse.Error(
1098+
Parse.Error.OBJECT_NOT_FOUND,
1099+
'A user with the email [email protected] does not exist.'
1100+
)
1101+
);
1102+
});
10851103
});

src/Routers/UsersRouter.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,9 @@ export class UsersRouter extends ClassesRouter {
406406
},
407407
err => {
408408
if (err.code === Parse.Error.OBJECT_NOT_FOUND) {
409-
// Return success so that this endpoint can't
410-
// be used to enumerate valid emails
411-
return Promise.resolve({
412-
response: {},
413-
});
414-
} else {
415-
throw err;
409+
err.message = `A user with the email ${email} does not exist.`;
416410
}
411+
throw err;
417412
}
418413
);
419414
}

0 commit comments

Comments
 (0)