Skip to content

Commit

Permalink
Invalidate caches after login attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Jan 7, 2022
1 parent a75a6ad commit 48953f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### Changed
- User caches are now invalidated after login attempts. ([#10313](https://github.com/craftcms/cms/discussions/10313))

### Deprecated
- Added `craft\helpers\App::parseEnv()` and `parseBooleanEnv()`, replacing their `Craft` class counterparts. ([#10319](https://github.com/craftcms/cms/discussions/10319))

Expand Down
6 changes: 6 additions & 0 deletions src/services/Users.php
Expand Up @@ -578,6 +578,9 @@ public function handleValidLogin(User $user)
// Update the User model too
$user->lastLoginDate = $now;
$user->invalidLoginCount = null;

// Invalidate caches
Craft::$app->getElements()->invalidateCachesForElement($user);
}

/**
Expand Down Expand Up @@ -635,6 +638,9 @@ public function handleInvalidLogin(User $user)
'user' => $user,
]));
}

// Invalidate caches
Craft::$app->getElements()->invalidateCachesForElement($user);
}

/**
Expand Down

0 comments on commit 48953f7

Please sign in to comment.