Skip to content
Snippets Groups Projects
Commit 3967b214 authored by Matthew Radcliffe's avatar Matthew Radcliffe
Browse files

Issue #3416657 by mradcliffe: Removes broken functionality to bypass frequency...

Issue #3416657 by mradcliffe: Removes broken functionality to bypass frequency 0 when changing password
parent b0662dfe
No related branches found
No related tags found
No related merge requests found
Pipeline #85536 passed with warnings
......@@ -39,3 +39,10 @@ user
Additionally admin pages are not affected by the agreement.
## Known issues
* When an agreement is configured to force a user to agree every login, and the
user changes their password, then the user must agree again. In previous
releases in Drupal 6 and Drupal 7, there was functionality that bypassed this,
but this is no longer possible in Drupal 8 or greater. This bypass has been
removed because it no longer is possible and caused PHP errors.
......@@ -9,30 +9,6 @@
*/
use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
use Drupal\Core\Entity\EntityInterface;
/**
* Implements hook_user_update().
*/
function agreement_user_update(EntityInterface $account) {
/** @var \Drupal\user\Entity\User $account */
if ($account->getEntityTypeId() === 'user') {
$current_user = \Drupal::currentUser();
$agreements = \Drupal::entityTypeManager()->getStorage('agreement')->loadMultiple();
/** @var \Drupal\agreement\Entity\Agreement $agreement */
foreach ($agreements as $agreement) {
// Do not require user to re-accept agreement if they've just changed
// their password.
$settings = $agreement->getSettings();
if ($settings['frequency'] === 0 &&
isset($account->original) &&
$account->checkExistingPassword($account->original) &&
$current_user->id() === $account->id()) {
\Drupal::service('agreement.handler')->agree($account, $agreement, 2);
}
}
}
}
/**
* Implements hook_mail().
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment