I use this hook pretty extensively to: E.g. Seed a new account with some data, add a new account to Stripe etc.
So far, everything has worked fine - I do what needs to be done onCreateUser
and then return the ‘user’ object as per the docs.
However, since updating to 1.8.2, suddenly all the code on the onCreateUser hook has started being ignored. It doesn’t run on new account creation at all.
To test things out, I removed all the logic in the hook and ran some tests:
Test 1 - Run come console logs to see if the code is running on new signups created:
…/server/accounts.js
...
Accounts.onCreateUser(
(
{ email, ...otherData },
user
) => {
console.log('On create user hook test, does this log');
console.log(email);
console.log(otherData);
console.log(user);
return user;
}
);
Outcome - no console output. User is created (basic user)
Test 2 - Same code as above but don’t return the user object at the end of the hook as should be done. The expected outcome here is for a new account creation attempt to fail.
Accounts.onCreateUser(
(
{ email, ...otherData },
user
) => {
console.log('On create user hook test, does this log');
console.log(email);
console.log(otherData);
console.log(user);
// return user;
}
);
Outcome - A user account is actually created without any error. Not sure why.
Test 3 - To ensure that the file where this hook is getting declared is loading correctly, test out other code in the file.
/server/accounts.js
Accounts.urls.resetPassword = function reset(token) {
return Meteor.absoluteUrl(`reset-password/${token}`);
};
Accounts.onCreateUser(
(
{ email, ...otherData },
user
) => {
console.log('On create user hook test, does this log');
console.log(email);
console.log(otherData);
console.log(user);
return user;
}
);
Test ran to see what account reset url is generated. Outcome - the custom URL specified for reset passwords gets sent out as expected, so the code is loading fine.
Does anyone have any ideas as to why onCreateUser has suddenly stopped working? And/or guidance on any extra tests to run to try and find the source of this issue?
Thanks!