Add option to redirect logged in users to destination

Created on 9 April 2025, 17 days ago

Problem/Motivation

Currently the "Enter email" form will display for both anonymous and authenticated users.

However, much of the time, it is only needed if the user is not logged in.

Steps to reproduce

Visit an "Enter your email" form as a logged in user. Note the form is displayed.

Proposed resolution

Add a check to VerifyEmailForm. If user is logged in, redirect to destination page.

Note: I think it would be useful to add an option to the settings to control this, but I think this can be a follow on issue.

Remaining tasks

  • In the constructor of VerifyEmailForm, add a property called currentUser of type Drupal\Core\Session\AccountProxyInterface
  • In the create function, populate with the current_user service
  • In the build() method, check $this->currentUser->isAuthenticated()
  • If it is true, redirect using $form_state->setRedirect('verify_email'.$entity);
  • Add a test in VerifyEmailRoutingTest, to log in as the admin user, navigate to email verification form, and verify page redirects to destination.

User interface changes

None

API changes

None

Data model changes

None

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇮🇪Ireland lostcarpark

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024