Problem/Motivation
In a website i have started using this module, i have noticed that when one user registers and logs in (without validate yet the email)
in their user page (/user), the field where i can see the state of the verification says "No" (as expected, mail is not verified)
After verifying the mail user gets redirected to the same page, but the field still says "No"
After performing 'drush cr', field value is changed to "Yes"
Not sure if this is just in my case (local site, ddev and cache configuration), or is a general issue, but if I apply the solution i propose below, the field's value is updated properly without CR
Steps to reproduce
Explained above
Proposed resolution
in user_email_verification.module
, under the function user_email_verification_user_view()
(line 66), add a '#cache' key to the elements that are being built:
if ($display->getComponent('user_email_verification_verified')) {
$build['user_email_verification_verified'] = [
'#type' => 'item',
'#title' => t('Email verified'),
'#markup' => '<span class="value">' . ($verification ? t('Yes') : t('No')) . '</span>',
'#wrapper_attributes' => ['class' => ['user-email-verification-is-verified']],
'#cache' => [
'contexts' => [
'user_email_verification_needed',
],
],
];
}
if ($display->getComponent('user_email_verification_verified_date') && $verification) {
$build['user_email_verification_verified_date'] = [
'#type' => 'item',
'#title' => t('Email verification date'),
'#markup' => '<span class="value">' . \Drupal::service('date.formatter')->format($verification, 'long') . '</span>',
'#wrapper_attributes' => ['class' => ['user-email-verification-verified-date']],
'#cache' => [
'contexts' => [
'user_email_verification_needed',
],
],
];
}
Remaining tasks
Create patch
Test if this issue happens to other people