mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
accounts: Allow specifying explicit errors in Meteor.validateNewUser
This commit is contained in:
@@ -156,6 +156,19 @@ if (Meteor.isClient) (function () {
|
||||
{invalid: true}, // should fail the new user validators
|
||||
expect(function (error) {
|
||||
test.equal(error.error, 403);
|
||||
test.equal(
|
||||
error.reason,
|
||||
"User validation failed");
|
||||
}));
|
||||
},
|
||||
logoutStep,
|
||||
function(test, expect) {
|
||||
Accounts.createUser({username: username3, password: password3},
|
||||
{invalidAndThrowException: true}, // should fail the new user validator with a special exception
|
||||
expect(function (error) {
|
||||
test.equal(
|
||||
error.reason,
|
||||
"An exception thrown within Accounts.validateNewUser");
|
||||
}));
|
||||
},
|
||||
// test Accounts.onCreateUser
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Accounts.validateNewUser(function (user) {
|
||||
if (user.invalidAndThrowException)
|
||||
throw new Meteor.Error(403, "An exception thrown within Accounts.validateNewUser");
|
||||
return !user.invalid;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user