Skip to content

Commit

Permalink
Finish compatibility with 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
daftspunk committed Aug 19, 2021
1 parent f346907 commit 7f7534a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 5 additions & 1 deletion components/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down Expand Up @@ -584,6 +587,7 @@ protected function makeRedirection($intended = false)
if ($property === '0') {
return;
}

// Refresh page
if ($property === '') {
return Redirect::refresh();
Expand Down
7 changes: 6 additions & 1 deletion components/ResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
}

//
Expand Down
12 changes: 9 additions & 3 deletions components/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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');
Expand All @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 7f7534a

Please sign in to comment.