Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent issues where user access is set concurrently #22931

Closed
wants to merge 22 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix saving access when not array
  • Loading branch information
caddoo committed Jan 14, 2025
commit 73da9f7a70cf334496ced40b321c9ad3cb915d7e
8 changes: 6 additions & 2 deletions plugins/UsersManager/API.php
Original file line number Diff line number Diff line change
@@ -103,15 +103,15 @@
private static $instance = null;

public function __construct(
Model $model,

Check failure on line 106 in plugins/UsersManager/API.php

GitHub Actions / PHPCS

Expected 1 space between type hint and argument "$model"; 24 found
UserAccessFilter $filter,

Check failure on line 107 in plugins/UsersManager/API.php

GitHub Actions / PHPCS

Expected 1 space between type hint and argument "$filter"; 13 found
Password $password,

Check failure on line 108 in plugins/UsersManager/API.php

GitHub Actions / PHPCS

Expected 1 space between type hint and argument "$password"; 21 found
?Access $access = null,

Check failure on line 109 in plugins/UsersManager/API.php

GitHub Actions / PHPCS

Expected 1 space between type hint and argument "$access"; 22 found
?Access\RolesProvider $roleProvider = null,

Check failure on line 110 in plugins/UsersManager/API.php

GitHub Actions / PHPCS

Expected 1 space between type hint and argument "$roleProvider"; 8 found
?Access\CapabilitiesProvider $capabilityProvider = null,
?PasswordVerifier $passwordVerifier = null

Check failure on line 112 in plugins/UsersManager/API.php

GitHub Actions / PHPCS

Expected 1 space between type hint and argument "$passwordVerifier"; 12 found
)
{

Check failure on line 114 in plugins/UsersManager/API.php

GitHub Actions / PHPCS

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
$this->model = $model;
$this->userFilter = $filter;
$this->password = $password;
@@ -639,7 +639,7 @@
$filter_search = null,
$filter_access = null
)
{

Check failure on line 642 in plugins/UsersManager/API.php

GitHub Actions / PHPCS

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Piwik::checkUserHasSomeAdminAccess();
$this->checkUserExists($userLogin);

@@ -899,7 +899,7 @@
$_isPasswordHashed = false,
$passwordConfirmation = false
)
{

Check failure on line 902 in plugins/UsersManager/API.php

GitHub Actions / PHPCS

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
$email = Common::unsanitizeInputValue($email);
$requirePasswordConfirmation = self::$UPDATE_USER_REQUIRE_PASSWORD_CONFIRMATION;
self::$UPDATE_USER_REQUIRE_PASSWORD_CONFIRMATION = true;
@@ -1173,11 +1173,15 @@
// if the access is noaccess then we don't save it as this is the default value
// when no access are specified
Piwik::postEvent('UsersManager.removeSiteAccess', [$userLogin, $idSites]);
} else {

Check failure on line 1176 in plugins/UsersManager/API.php

GitHub Actions / PHPCS

Blank line found at start of control structure

if (empty($idSitesAndAccess)) {
$role = array_shift($roles);
$this->model->addUserAccess($userLogin, $role, $idSites);
if (is_array($roles) && !empty($roles)) {
$role = array_shift($roles);
$this->model->addUserAccess($userLogin, $role, $idSites);
} else {
$this->model->addUserAccess($userLogin, $access, $idSites);
}
}

foreach ($idSitesAndAccess as $idSite => $previousAccess) {
Loading