Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
verify_email
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
verify_email
Commits
5941e868
Commit
5941e868
authored
1 month ago
by
Nidhi Patadia
Committed by
James Shields
1 month ago
Browse files
Options
Downloads
Patches
Plain Diff
Add option to redirect logged in users to destination.
parent
2c1e6d51
No related branches found
No related tags found
1 merge request
!11
Add option to redirect logged in users to destination.
Pipeline
#470224
passed
1 month ago
Stage: build
Stage: validate
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Form/VerifyEmailForm.php
+9
-2
9 additions, 2 deletions
src/Form/VerifyEmailForm.php
tests/src/Functional/VerifyEmailRoutingTest.php
+11
-0
11 additions, 0 deletions
tests/src/Functional/VerifyEmailRoutingTest.php
with
20 additions
and
2 deletions
src/Form/VerifyEmailForm.php
+
9
−
2
View file @
5941e868
...
@@ -7,10 +7,12 @@
...
@@ -7,10 +7,12 @@
use
Drupal\Component\Utility\EmailValidatorInterface
;
use
Drupal\Component\Utility\EmailValidatorInterface
;
use
Drupal\Core\Form\FormBase
;
use
Drupal\Core\Form\FormBase
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Session\AccountProxyInterface
;
use
Drupal\Core\Url
;
use
Drupal\verify_email
\Service\VerifierInterface
;
use
Drupal\verify_email
\Service\VerifierInterface
;
use
Drupal\verify_email
\VerifyEmailInterface
;
use
Drupal\verify_email
\VerifyEmailInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Drupal\Core\Url
;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
/**
/**
* Provides a Verify Email form.
* Provides a Verify Email form.
...
@@ -21,6 +23,7 @@ final class VerifyEmailForm extends FormBase {
...
@@ -21,6 +23,7 @@ final class VerifyEmailForm extends FormBase {
* Constructs a new VerifyEmailForm.
* Constructs a new VerifyEmailForm.
*/
*/
public
function
__construct
(
public
function
__construct
(
protected
readonly
AccountProxyInterface
$currentUser
,
protected
readonly
EmailValidatorInterface
$emailValidator
,
protected
readonly
EmailValidatorInterface
$emailValidator
,
protected
readonly
VerifierInterface
$verifier
,
protected
readonly
VerifierInterface
$verifier
,
)
{}
)
{}
...
@@ -30,6 +33,7 @@ public function __construct(
...
@@ -30,6 +33,7 @@ public function __construct(
*/
*/
public
static
function
create
(
ContainerInterface
$container
):
self
{
public
static
function
create
(
ContainerInterface
$container
):
self
{
return
new
static
(
return
new
static
(
$container
->
get
(
'current_user'
),
$container
->
get
(
'email.validator'
),
$container
->
get
(
'email.validator'
),
$container
->
get
(
'verify_email.verifier'
),
$container
->
get
(
'verify_email.verifier'
),
);
);
...
@@ -45,9 +49,12 @@ public function getFormId(): string {
...
@@ -45,9 +49,12 @@ public function getFormId(): string {
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
buildForm
(
array
$form
,
FormStateInterface
$form_state
,
VerifyEmailInterface
|
null
$entity
=
NULL
):
array
{
public
function
buildForm
(
array
$form
,
FormStateInterface
$form_state
,
VerifyEmailInterface
|
null
$entity
=
NULL
):
RedirectResponse
|
array
{
$form_state
->
set
(
'entity'
,
$entity
);
$form_state
->
set
(
'entity'
,
$entity
);
if
(
$this
->
currentUser
()
->
isAuthenticated
())
{
return
new
RedirectResponse
(
$entity
->
getRedirectPath
());
}
$form
[
'intro'
]
=
[
$form
[
'intro'
]
=
[
'#markup'
=>
$entity
->
getIntro
(),
'#markup'
=>
$entity
->
getIntro
(),
...
...
This diff is collapsed.
Click to expand it.
tests/src/Functional/VerifyEmailRoutingTest.php
+
11
−
0
View file @
5941e868
...
@@ -86,6 +86,17 @@ public function testVerifyEmailRoute(): void {
...
@@ -86,6 +86,17 @@ public function testVerifyEmailRoute(): void {
$this
->
assertSession
()
->
pageTextContains
(
'Enter your email address.'
);
$this
->
assertSession
()
->
pageTextContains
(
'Enter your email address.'
);
}
}
/**
* Test the verify email form for authenticated user.
*/
public
function
testVerifyEmailRouteAuthenticatedUser
():
void
{
$this
->
drupalLogin
(
$this
->
adminUser
);
$this
->
drupalGet
(
'/verify-email-form'
);
// Test redirection.
$this
->
assertSession
()
->
addressEquals
(
'node/1'
);
$this
->
drupalLogout
();
}
/**
/**
* Tests invalid email validation.
* Tests invalid email validation.
*/
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment