Skip to content

Commit

Permalink
Merge branch 'release/3.3.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Dec 3, 2020
2 parents 4f0506c + c9fc7d0 commit 88944f7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v3.3.7
## 12/02/2020

1. [](#bugfix)
* Flex Users: Make sure the user object is fresh and not cached

# v3.3.6
## 09/24/2020

Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Login
slug: login
type: plugin
version: 3.3.6
version: 3.3.7
testing: false
description: Enables user authentication and login screen.
icon: sign-in
Expand Down
4 changes: 4 additions & 0 deletions classes/Events/UserLoginEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ public function __construct(array $items = [])
/** @var UserCollectionInterface $users */
$users = Grav::instance()['accounts'];
$user = $users->load($this['credentials']['username']);
if (is_callable([$user, 'refresh'])) {
$user->refresh();
}

$this->offsetSet('user', $user);

if (Login::DEBUG) {
Expand Down
10 changes: 10 additions & 0 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public function onSessionStart(SessionStartEvent $event)
/** @var UserObject $stored */
if ($accounts instanceof FlexCollectionInterface) {
$stored = $accounts[$user->username];
if (is_callable([$stored, 'refresh'])) {
$stored->refresh();
}
} else {
// TODO: remove when removing legacy support.
$stored = $accounts->load($user->username);
Expand Down Expand Up @@ -439,6 +442,9 @@ public function handleUserActivation()

$token = $uri->param('token');
$user = $users->load($username);
if (is_callable([$user, 'refresh'])) {
$user->refresh();
}

$redirect_route = $this->config->get('plugins.login.user_registration.redirect_after_activation');
$redirect_code = null;
Expand Down Expand Up @@ -1086,6 +1092,10 @@ public function userLoginAuthenticateByRememberMe(UserLoginEvent $event)

// Allow remember me to work with different login methods.
$user = $users->load($username);
if (is_callable([$user, 'refresh'])) {
$user->refresh();
}

$event->setCredential('username', $username);
$event->setUser($user);

Expand Down

0 comments on commit 88944f7

Please sign in to comment.