I created a Pre-Registration hook.
I have a rule that refuse de user creation (duplicated user).
In case of error, I use the following code to reject the creation :
cb(users.length + ’ account(s) already exists ’ null, context);
But the user doesn’t receive any explaination about the failure :
The Hooks currently don’t allow to return a proper customized error message; when a Hook fails, it just returns a generic 500 http status with a generic error message (“An error occured”). Therefore, Hooks can’t currently be used properly for such kind of input validation.
But we are aware of the limitation and the product team is discussing this internally, so custom error messages will most likely be supported in the future at some point. But for now, it’s not possible.
The requirement is present on the forum for more than 2 years and are quite popular threads.
“At the Pre User Registration extensibility point, Hooks allow custom actions to be executed when a new user is created. For example, you may add custom app_metadata or user_metadata to the newly-created user, or even prevent the creation of the user in the database.”
It’s hard to understand that we can prevent a user request but not give him feedback…
Yes, I totally understand. However, there are many other feature requests in the product log, including those that don’t up in the community forum. The demand is definitely measured, but of course it’s not just based on community forum posts popularity, but also other factors. But I totally understand that it would be helpful to have this, and of course the sooner the better.
As this topic is related to Rules - Hooks - Actions and Rules & Hooks are being deprecated soon I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!