Problem/Motivation

Both submit handlers in the .module file call SubscriptionManagerService::shouldRedirectCurrentUserOnLogin(), which loads \Drupal::currentUser(). On the login form that is the account that just logged in. On the register form it is whoever submitted the form:

  • With core's default "require e-mail verification", or with administrator approval, the registrant is still anonymous after submit. The service loads uid 0, finds no subscription, polls the connectors, and if they vote to redirect it replaces core's redirect to the front page (where the "instructions have been sent to your e-mail" message shows) with the subscribe route, which requires manage own subscriptions. The new registrant sees a 403 instead of the confirmation.
  • At /admin/people/create the current user is the administrator, so the administrator is the one redirected to the plan chooser after creating someone else's account.

Neither submit handler has a test. The destination check in the service reads the POST body only, never the query string the login form carries; harmless today because core's redirect subscriber wins, but equally untested.

Proposed resolution

  • In the register submit handler, redirect only when the current user is authenticated and is the account the form just created ($form_state->get('user'), which core sets); otherwise leave core's redirect alone.
  • Functional tests with the test connectors voting to redirect: registration with e-mail verification lands on the front page with the status message; registration with verification off and immediate login lands on the chooser; an administrator creating an account is not redirected; login with a destination query is not redirected.

Remaining tasks

  • Implementation and tests; no change record (behaviour fix only).

User interface changes

None intended; the 403 goes away.

API changes

None.

Data model changes

None.

Comments

colan created an issue.