-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
data in "before create" hooks is empty #80
Comments
Thank you for the detailed report. This is indeed a bug that I've introduced a week before the release (initially the events were operating on the form instance which is populated before triggering the hook). It'll be fixed in the next v0.3.0 version (together with the nullable field controls). |
I've decided to release the fix for this in v0.2.4 because it could be a blocker if someone is using PocketBase as a framework. The form request unit tests were update to reflect the change, but we'll have to think how to improve the integration tests for the api, because currently we are verifying only whether the hook was triggered or not, but there is no easy way to test the hook(s) data. @invakid404 Please test it and if you stumble on something, feel free to let me know and I'll investigate it further. |
@ganigeorgiev thanks for the fast response, I can confirm that the The password hash isn't shown in the JSON output, but I've checked manually, and it's properly set as well. Looks good to me so far :^) |
While playing around with using PocketBase as a framework, I noticed that the
User
in theOnUserBeforeCreateRequest
hook is empty. Let's take the following hook as an example:When I create a user, I get the following output:
All fields appear to be empty. By stepping through the "user create" endpoint with a debugger, I observed this:
form
, butReading through the code, I confirmed that the user struct's fields don't get touched until
Submit()
is called on the form: here.And since
Submit()
isn't called until theOnUserBeforeCreateRequest
hooks have finished executing, the hooks don't get access to the user that's about to be created.This definitely doesn't sound like expected behavior (otherwise that hook would be very useless indeed). Without really knowing how this project is structured, it seems like the field setting portion of
Submit()
should happen earlier somewhere.This appears to be the case with other "before create" hooks. I also tried the "OnRecordBeforeCreateRequest" hook, but the record in there has no data whatsoever either, besides the "@collectionId" and "@collectionName" fields. Calling
.Data()
on it doesn't help much either, a blank map is returned.The text was updated successfully, but these errors were encountered: