Skip to content

Commit

Permalink
avoid to impersonate inactive users or without profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
orthagh authored and trasher committed May 24, 2022
1 parent 747818d commit dfe8065
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -1598,10 +1598,23 @@ public static function canImpersonate($user_id)
return false; // Cannot impersonate invalid user, self, or already impersonated user
}

// For now we do not check more than config update right, but we may
// implement more fine checks in the future.
// Cannot impersonate if we don't have config right
if (!self::haveRight(Config::$rightname, UPDATE)) {
return false;
}

// Cannot impersonate inactive user
$user = new User();
if (!$user->getFromDB($user_id) || !$user->getField('is_active')) {
return false;
}

return self::haveRight(Config::$rightname, UPDATE);
// Cannot impersonate user with no profile
if (Profile_User::getUserProfiles($user_id, true) == []) {
return false;
}

return true;
}

/**
Expand Down

0 comments on commit dfe8065

Please sign in to comment.