Skip to content

Commit

Permalink
Don't call handleValidLogin() when impersonating a user
Browse files Browse the repository at this point in the history
Resolves #4130
  • Loading branch information
brandonkelly committed Apr 16, 2019
1 parent 753344f commit 0e551dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Fixed PHP type errors that could occur when calling some deprecated `craft.request` methods in templates. ([#4124](https://github.com/craftcms/cms/issues/4124))
- Fixed performance issues that could occur where uploading GIFs in the Control Panel.
- Fixed a bug where it wasn’t possible to create a new global set with the same name or handle as a soft-deleted one. ([#4091](https://github.com/craftcms/cms/issues/4091))
- Fixed a bug where pending users’ verification codes were getting deleted if they were impersonated by an admin. ([#4130](https://github.com/craftcms/cms/issues/4130))

## 3.1.22 - 2019-04-10

Expand Down
7 changes: 5 additions & 2 deletions src/web/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ protected function afterLogin($identity, $cookieBased, $duration)
$session = Craft::$app->getSession();

// Save the username cookie if they're not being impersonated
if ($session->get(UserElement::IMPERSONATE_KEY) === null) {
$impersonating = $session->get(UserElement::IMPERSONATE_KEY) !== null;
if (!$impersonating) {
$this->sendUsernameCookie($identity);
}

Expand All @@ -415,7 +416,9 @@ protected function afterLogin($identity, $cookieBased, $duration)
$session->remove($this->elevatedSessionTimeoutParam);

// Update the user record
Craft::$app->getUsers()->handleValidLogin($identity);
if (!$impersonating) {
Craft::$app->getUsers()->handleValidLogin($identity);
}

parent::afterLogin($identity, $cookieBased, $duration);
}
Expand Down

0 comments on commit 0e551dc

Please sign in to comment.