Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

The 'user.registering' event doesn't return errors added by addons #2514

Open
aryehraber opened this issue Apr 18, 2020 · 1 comment
Open

Comments

@aryehraber
Copy link

I'm adding Recaptcha support for Statamic's user registration form by listening to the 'user.registering' event. On failure, I return errors which are captured by the runRegisteringEvent() method which in turn passes the MessageBag back to the register() method... so far so good!

The registration form correctly stops further processing and returns back, however the errors aren't available inside {{ errors }}.

Solution:

The issue is line 178 of the UserListener class:

return back()->withInput()->withErrors($errors);

The withErrors method is missing the errors key:

return back()->withInput()->withErrors($errors, 'userRegister');

By adding this key (also used by the registration validator on line 168), I'm able to correctly receive and render the error inside templates.

@alehandrof
Copy link

Is this still an issue?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants