Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/drupal#54 Remove hook_user_login, fixes the masquerade module #31

Merged
merged 1 commit into from
Jul 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions civicrm.user.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ use Drupal\Core\Session\AccountInterface;
* Implements hook_user_login().
*/
function civicrm_user_login(AccountInterface $account) {
$civicrm = \Drupal::service('civicrm');
$civicrm->initialize();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not be necessary, but the other functions do it, so I figured it was safer. I didn't want to create a new wrapper function in src/Civicrm.php just for getSession or equivalent (as was done for the synchronize function)


if (\Drupal::hasService('masquerade')) {
// https://github.com/civicrm/civicrm-drupal-8/pull/31
// In theory this is harmless whether we masquerade or not, but for now narrowing
// the scope, in case it causes regressions.
// Not using isMasquerading() because it does not seem to be
// initialized at this point (it always returns false).
\CRM_Core_Session::singleton()->reset(FALSE);
}

\Drupal::service('civicrm')->synchronizeUser($account);
}
Copy link
Member

@monishdeb monishdeb Sep 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to reduce LOC

function civicrm_user_login(AccountInterface $account) {
  $civicrm = \Drupal::service('civicrm');
  $civicrm->initialize();

  if (\Drupal::hasService('masquerade')) {
    // In theory this is harmless whether we masquerade or not, but for now narrowing
    // the scope, in case it causes regressions.
    // Also, there is a isMasquerading() function, but it does not seem to be
    // initialized at this point (it always returns false).
    \CRM_Core_Session::singleton()->reset(FALSE);
  }
  $civicrm->synchronizeUser($account);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works!


Expand Down