-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
|
||
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); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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);
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 fixed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It works! |
||
|
||
|
There was a problem hiding this comment.
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 forgetSession
or equivalent (as was done for the synchronize function)