Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit 15436c8

Browse files
committed
Reload roles when changing groupPath or Profile on a user
1 parent f6247b5 commit 15436c8

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

core/src/core/src/pydio/Core/Services/UsersService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public static function updatePassword($userId, $userPass)
376376
public static function createUser($userId, $userPass, $isAdmin = false, $isHidden = false)
377377
{
378378
$userId = self::filterUserSensitivity($userId);
379-
$localContext = new Context($userId, null);
379+
$localContext = Context::emptyContext();
380380
Controller::applyHook("user.before_create", array($localContext, $userId, $userPass, $isAdmin, $isHidden));
381381
if (!ConfService::getGlobalConf("ALLOW_GUEST_BROWSING", "auth") && $userId == "guest") {
382382
throw new \Exception("Reserved user id");

core/src/plugins/conf.sql/SqlUser.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ public function load()
343343
$this->groupPath = $res->fetchSingle();
344344
if (empty($this->groupPath)) {
345345
// Auto migrate from old version
346-
$this->setGroupPath("/");
346+
$this->groupPath = "/";
347347
}
348348

349349
$result_rights = dibi::query('SELECT [repo_uuid], [rights] FROM [ajxp_user_rights] WHERE [login] = %s', $this->getId());
@@ -413,6 +413,9 @@ public function load()
413413
if (count($rolesToLoad)) {
414414
$allRoles = RolesService::getRolesList($rolesToLoad);
415415
foreach ($rolesToLoad as $roleId) {
416+
if (!isSet($allRoles[$roleId]) && strpos($roleId, "AJXP_GRP_/") === 0){
417+
$allRoles[$roleId] = RolesService::getOrCreateRole($roleId);
418+
}
416419
if (isSet($allRoles[$roleId])) {
417420
$this->roles[$roleId] = $allRoles[$roleId];
418421
$this->rights["ajxp.roles"][$roleId] = true;
@@ -581,6 +584,8 @@ public function setGroupPath($groupPath, $update = false)
581584
}
582585
parent::setGroupPath($groupPath);
583586
dibi::query('UPDATE [ajxp_users] SET ', Array('groupPath'=>$groupPath), 'WHERE [login] = %s', $this->getId());
587+
$this->load();
588+
$this->recomputeMergedRole();
584589
$this->log('UPDATE GROUP: [Login]: '.$this->getId().' [Group]:'.$groupPath);
585590
}
586591

core/src/plugins/core.conf/AbstractUser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ public function getProfile()
239239
public function setProfile($profile)
240240
{
241241
$this->rights["ajxp.profile"] = $profile;
242+
RolesService::updateAutoApplyRole($this);
242243
}
243244

244245
/**

0 commit comments

Comments
 (0)