mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Merge pull request #7968 from hwillson/issue-5676
Preventing undefined callback from being passed into the forgotPassword Method
This commit is contained in:
@@ -220,7 +220,12 @@ Accounts.forgotPassword = function(options, callback) {
|
||||
if (!options.email) {
|
||||
return reportError(new Meteor.Error(400, "Must pass options.email"), callback);
|
||||
}
|
||||
Accounts.connection.call("forgotPassword", options, callback);
|
||||
|
||||
if (callback) {
|
||||
Accounts.connection.call("forgotPassword", options, callback);
|
||||
} else {
|
||||
Accounts.connection.call("forgotPassword", options);
|
||||
}
|
||||
};
|
||||
|
||||
// Resets a password based on a token originally created by
|
||||
|
||||
@@ -2,7 +2,7 @@ Accounts._noConnectionCloseDelayForTest = true;
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Accounts.removeDefaultRateLimit();
|
||||
|
||||
|
||||
Meteor.methods({
|
||||
getResetToken: function () {
|
||||
var token = Meteor.users.findOne(this.userId).services.password.reset;
|
||||
@@ -557,8 +557,8 @@ if (Meteor.isClient) (function () {
|
||||
}, 10 * 1000, 100);
|
||||
}
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
||||
testAsyncMulti("passwords - forgotPassword client return error when empty email", [
|
||||
function (test, expect) {
|
||||
// setup
|
||||
@@ -578,7 +578,36 @@ if (Meteor.isClient) (function () {
|
||||
}, /Must pass options\.email/);
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
Tinytest.add(
|
||||
'passwords - forgotPassword only passes callback value to forgotPassword '
|
||||
+ 'Method if callback is defined (to address issue #5676)',
|
||||
function (test) {
|
||||
let methodCallArgumentCount = 0;
|
||||
const originalMethodCall = Accounts.connection.call;
|
||||
const stubMethodCall = (...args) => {
|
||||
methodCallArgumentCount = args.length;
|
||||
}
|
||||
Accounts.connection.call = stubMethodCall;
|
||||
|
||||
Accounts.forgotPassword({ email: 'test@meteor.com' });
|
||||
test.equal(
|
||||
methodCallArgumentCount,
|
||||
2,
|
||||
'Method call should have 2 arguments since no callback is passed in'
|
||||
);
|
||||
|
||||
Accounts.forgotPassword({ email: 'test@meteor.com' }, () => {});
|
||||
test.equal(
|
||||
methodCallArgumentCount,
|
||||
3,
|
||||
'Method call should have 3 arguments since a callback is passed in'
|
||||
);
|
||||
|
||||
Accounts.connection.call = originalMethodCall;
|
||||
}
|
||||
);
|
||||
|
||||
testAsyncMulti("passwords - verifyEmail client return error when empty token", [
|
||||
function (test, expect) {
|
||||
// setup
|
||||
@@ -598,7 +627,7 @@ if (Meteor.isClient) (function () {
|
||||
}, /Need to pass token/);
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
testAsyncMulti("passwords - resetPassword errors", [
|
||||
function (test, expect) {
|
||||
// setup
|
||||
|
||||
Reference in New Issue
Block a user