Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
fix(install): allow super-admin to update invitation (issue #84)
Browse files Browse the repository at this point in the history
  • Loading branch information
DIOHz0r committed Nov 7, 2017
1 parent 0100a0d commit 1f05a7a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion install/installer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ protected function createFirstAccess() {

$newRights = [
PluginFlyvemdmProfile::$rightname => PluginFlyvemdmProfile::RIGHT_FLYVEMDM_USE,
PluginFlyvemdmInvitation::$rightname => CREATE | READ | DELETE | PURGE,
PluginFlyvemdmInvitation::$rightname => ALLSTANDARDRIGHT,
PluginFlyvemdmAgent::$rightname => READ | UPDATE | PURGE | READNOTE | UPDATENOTE,
PluginFlyvemdmFleet::$rightname => ALLSTANDARDRIGHT | READNOTE | UPDATENOTE,
PluginFlyvemdmPackage::$rightname => ALLSTANDARDRIGHT | READNOTE | UPDATENOTE,
Expand Down
7 changes: 4 additions & 3 deletions install/upgrade/update_to_dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ function plugin_flyvemdm_update_to_dev(Migration $migration) {
$profileRight = new ProfileRight();

// Merge new rights into current profile
$currentRights = ProfileRight::getProfileRights($_SESSION['glpiactiveprofile']['id']);
$profiles_id = $_SESSION['glpiactiveprofile']['id'];
$currentRights = ProfileRight::getProfileRights($profiles_id);
$newRights = array_merge($currentRights, [
PluginFlyvemdmInvitation::$rightname => CREATE | READ | UPDATE | DELETE | PURGE,
PluginFlyvemdmInvitation::$rightname => ALLSTANDARDRIGHT ,
PluginFlyvemdmInvitationlog::$rightname => READ,
PluginFlyvemdmGeolocation::$rightname => ALLSTANDARDRIGHT | READNOTE | UPDATENOTE,
PluginFlyvemdmTask::$rightname => READ,
]);
$profileRight->updateProfileRights($_SESSION['glpiactiveprofile']['id'], $newRights);
$profileRight->updateProfileRights($profiles_id, $newRights);

// remove download base URL setting
Config::deleteConfigurationValues('flyvemdm', ['deploy_base_url']);
Expand Down
5 changes: 4 additions & 1 deletion tests/suite-integration/ProfileRight.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public function testAgentProfileRights() {
}
}

/**
* @tags testSuperAdminProfileRights
*/
public function testSuperAdminProfileRights() {
$profileId = 4; // Super admin profile ID

Expand All @@ -102,7 +105,7 @@ public function testSuperAdminProfileRights() {
| PluginFlyvemdmEntityconfig::RIGHT_FLYVEMDM_DEVICE_COUNT_LIMIT
| PluginFlyvemdmEntityconfig::RIGHT_FLYVEMDM_APP_DOWNLOAD_URL
| PluginFlyvemdmEntityconfig::RIGHT_FLYVEMDM_INVITATION_TOKEN_LIFE,
PluginFlyvemdmInvitation::$rightname => CREATE | READ | DELETE | PURGE,
PluginFlyvemdmInvitation::$rightname => ALLSTANDARDRIGHT,
PluginFlyvemdmInvitationLog::$rightname => READ,
];

Expand Down

0 comments on commit 1f05a7a

Please sign in to comment.