Permalink
Browse files

Reload roles when changing groupPath or Profile on a user

  • Loading branch information...
1 parent f6247b5 commit 15436c8425bd421e82ec60abf9969b38bd84617e @cdujeu cdujeu committed Oct 13, 2016
@@ -376,7 +376,7 @@ public static function updatePassword($userId, $userPass)
public static function createUser($userId, $userPass, $isAdmin = false, $isHidden = false)
{
$userId = self::filterUserSensitivity($userId);
- $localContext = new Context($userId, null);
+ $localContext = Context::emptyContext();
Controller::applyHook("user.before_create", array($localContext, $userId, $userPass, $isAdmin, $isHidden));
if (!ConfService::getGlobalConf("ALLOW_GUEST_BROWSING", "auth") && $userId == "guest") {
throw new \Exception("Reserved user id");
@@ -343,7 +343,7 @@ public function load()
$this->groupPath = $res->fetchSingle();
if (empty($this->groupPath)) {
// Auto migrate from old version
- $this->setGroupPath("/");
+ $this->groupPath = "/";
}
$result_rights = dibi::query('SELECT [repo_uuid], [rights] FROM [ajxp_user_rights] WHERE [login] = %s', $this->getId());
@@ -413,6 +413,9 @@ public function load()
if (count($rolesToLoad)) {
$allRoles = RolesService::getRolesList($rolesToLoad);
foreach ($rolesToLoad as $roleId) {
+ if (!isSet($allRoles[$roleId]) && strpos($roleId, "AJXP_GRP_/") === 0){
+ $allRoles[$roleId] = RolesService::getOrCreateRole($roleId);
+ }
if (isSet($allRoles[$roleId])) {
$this->roles[$roleId] = $allRoles[$roleId];
$this->rights["ajxp.roles"][$roleId] = true;
@@ -581,6 +584,8 @@ public function setGroupPath($groupPath, $update = false)
}
parent::setGroupPath($groupPath);
dibi::query('UPDATE [ajxp_users] SET ', Array('groupPath'=>$groupPath), 'WHERE [login] = %s', $this->getId());
+ $this->load();
+ $this->recomputeMergedRole();
$this->log('UPDATE GROUP: [Login]: '.$this->getId().' [Group]:'.$groupPath);
}
@@ -239,6 +239,7 @@ public function getProfile()
public function setProfile($profile)
{
$this->rights["ajxp.profile"] = $profile;
+ RolesService::updateAutoApplyRole($this);
}
/**

0 comments on commit 15436c8

Please sign in to comment.