From 7f7534a0ea192666d2b4df4ec940c708f9668a76 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Thu, 19 Aug 2021 14:34:36 +1000 Subject: [PATCH] Finish compatibility with 2.0 --- Plugin.php | 2 +- components/Account.php | 6 +++++- components/ResetPassword.php | 7 ++++++- components/Session.php | 12 +++++++++--- updates/version.yaml | 1 + 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Plugin.php b/Plugin.php index 75835d68..0152481c 100644 --- a/Plugin.php +++ b/Plugin.php @@ -32,7 +32,7 @@ public function pluginDetails() public function register() { $alias = AliasLoader::getInstance(); - $alias->alias('Auth', 'RainLab\User\Facades\Auth'); + $alias->alias('Auth', \RainLab\User\Facades\Auth::class); App::singleton('user.auth', function () { return \RainLab\User\Classes\AuthManager::instance(); diff --git a/components/Account.php b/components/Account.php index c07a7406..8514eaac 100644 --- a/components/Account.php +++ b/components/Account.php @@ -66,7 +66,10 @@ public function defineProperties() public function getRedirectOptions() { - return [''=>'- refresh page -', '0' => '- no redirect -'] + Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName'); + return [ + '' => '- refresh page -', + '0' => '- no redirect -' + ] + Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName'); } /** @@ -584,6 +587,7 @@ protected function makeRedirection($intended = false) if ($property === '0') { return; } + // Refresh page if ($property === '') { return Redirect::refresh(); diff --git a/components/ResetPassword.php b/components/ResetPassword.php index 152218a2..d08af410 100644 --- a/components/ResetPassword.php +++ b/components/ResetPassword.php @@ -10,7 +10,7 @@ use RainLab\User\Models\User as UserModel; /** - * Password reset workflow + * ResetPassword controls the password reset workflow * * When a user has forgotten their password, they are able to reset it using * a unique token that, sent to their email address upon request. @@ -133,6 +133,11 @@ public function onResetPassword() if (!$user->attemptResetPassword($code, post('password'))) { throw new ValidationException($errorFields); } + + // Check needed for compatbility with legacy systems + if (method_exists(\RainLab\User\Classes\AuthManager::class, 'clearThrottleForUserId')) { + Auth::clearThrottleForUserId($user->id); + } } // diff --git a/components/Session.php b/components/Session.php index 0236cfe3..60d41d2d 100644 --- a/components/Session.php +++ b/components/Session.php @@ -13,7 +13,7 @@ use ValidationException; /** - * User session + * Session component * * This will inject the user object to every page and provide the ability for * the user to sign out. This can also be used to restrict access to pages. @@ -62,11 +62,17 @@ public function defineProperties() ]; } + /** + * getRedirectOptions + */ public function getRedirectOptions() { return [''=>'- none -'] + Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName'); } + /** + * getAllowedUserGroupsOptions + */ public function getAllowedUserGroupsOptions() { return UserGroup::lists('name','code'); @@ -91,7 +97,7 @@ public function onRun() if (empty($this->property('redirect'))) { throw new \InvalidArgumentException('Redirect property is empty'); } - + $redirectUrl = $this->controller->pageUrl($this->property('redirect')); return Redirect::guest($redirectUrl); } @@ -178,7 +184,7 @@ public function onStopImpersonating() protected function checkUserSecurity() { $allowedGroup = $this->property('security', self::ALLOW_ALL); - $allowedUserGroups = $this->property('allowedUserGroups', []); + $allowedUserGroups = (array) $this->property('allowedUserGroups', []); $isAuthenticated = Auth::check(); if ($isAuthenticated) { diff --git a/updates/version.yaml b/updates/version.yaml index c70c4036..c5502761 100644 --- a/updates/version.yaml +++ b/updates/version.yaml @@ -75,3 +75,4 @@ 1.5.3: Fixes a bug in the user update functionality if password is not changed. Added highlighting for banned users in user list. 1.5.4: Multiple translation improvements. Added view events to extend user preview and user listing toolbars. 1.5.5: Updated settings icon and description. +1.6.0: Apply persistence settings on activation and registration. Fixes last seen touched when impersonating. Fixes user suspension not clearing.