Skip to content

Instantly share code, notes, and snippets.

@labboy0276
Created March 7, 2019 20:22
Show Gist options
  • Save labboy0276/e62bf7b46359f3623dc30efeeae05fb6 to your computer and use it in GitHub Desktop.
Save labboy0276/e62bf7b46359f3623dc30efeeae05fb6 to your computer and use it in GitHub Desktop.
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 053429f4b8..44d3c5c898 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -561,8 +561,22 @@ function user_login_finalize(UserInterface $account) {
// This is called before hook_user_login() in case one of those functions
// fails or incorrectly does a redirect which would leave the old session
// in place.
- \Drupal::service('session')->migrate();
- \Drupal::service('session')->set('uid', $account->id());
+ $skip = FALSE;
+ $moduleHandler = \Drupal::service('module_handler');
+ if ($moduleHandler->moduleExists('poets_api_login') && $moduleHandler->moduleExists('social_login')) {
+ $redirect = \Drupal::service('poets_api_login.redirect');
+ $request = \Drupal::request();
+ $cookies = $request->cookies->all();
+ $url = parse_url($cookies["referer"]);
+ if (isset($url['host']) && in_array($url['host'], $redirect->whiteList())) {
+ $skip = TRUE;
+ }
+ }
+
+ if (!$skip) {
+ \Drupal::service('session')->migrate();
+ \Drupal::service('session')->set('uid', $account->id());
+ }
\Drupal::moduleHandler()->invokeAll('user_login', [$account]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment