A registration form may have newsletter information or be guarded by reCaptcha. In a decoupled scenario this is almost impossible to handle since we cannot just alter the form and its submission. Having an event that passed the account to be created and the resource document would allow this.

A client could pass reCaptcha data in the request document's meta properties and then a subscriber to the event could validate the information.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mglaman created an issue. See original summary.

mglaman’s picture

Status: Active » Needs work
FileSize
4.81 KB

Slight problem:

    $event = new RegistrationEvent($created_entity, $document);
    $this->eventDispatcher->dispatch(UserResourcesEvents::USER_REGISTRATION, $event);

To run this before the user is saved, we need to run it in modifyCreatedEntity. Which we don't have access to the JSON:API document.

Instead of rewriting everything, maybe modifyCreatedEntity should also pass the document data along with the request.

mglaman’s picture

Title: Fire an event to allow modules to react to user registration » [PP-1] Fire an event to allow modules to react to user registration
Status: Needs work » Postponed
mglaman’s picture

Title: [PP-1] Fire an event to allow modules to react to user registration » Fire an event to allow modules to react to user registration
Status: Postponed » Active

jsonapi_resources 1.0-beta3 landed with the required code!

mglaman’s picture

Status: Active » Needs review
FileSize
7.71 KB

Here is an updated patch that retrieves the document from the request.

mglaman’s picture

This adds tests. Also has pending test coverage for metadata support once #3105792: Add support for the meta property lands.

mglaman’s picture

FileSize
14.35 KB
mglaman’s picture

FileSize
14.65 KB

Fixes up phpcs

  • mglaman committed 81d1b5a on 8.x-1.x
    Issue #3104957 by mglaman: Fire an event to allow modules to react to...
mglaman’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.