Compare commits

...

2 Commits

Author SHA1 Message Date
Anne-Cath
c347b961b1 9622 - Error in the user story life cycle 2026-05-21 10:31:49 +02:00
Benjamin DALSASS
48e6203869 N°9044 - Application token and Impersonate (Log in as this user) 2026-05-13 11:14:58 +02:00
2 changed files with 20 additions and 1 deletions

View File

@@ -3240,7 +3240,13 @@ EOF
$aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, $aArgs);
if (is_array($aAllowedValues) && count($aAllowedValues) == 1) {
$aValues = array_keys($aAllowedValues);
$this->Set($sAttCode, $aValues[0]);
if ($oAttDef->IsLinkSet()) {
$oObjectSet = $this->Get($sAttCode);
$oObjectSet->AddItem(MetaModel::GetObject($oAttDef->GetLinkedClass(), $aValues[0]));
$this->Set($sAttCode, $oObjectSet);
} else {
$this->Set($sAttCode, $aValues[0]);
}
}
}
}

View File

@@ -658,6 +658,16 @@ abstract class User extends cmdbAbstractObject
}
return false;
}
/**
* Allow a user to be impersonated by another one (generally an administrator) in order to troubleshoot rights issues.
*
* @return bool
*/
public function CanBeImpersonated(): bool
{
return true;
}
}
/**
@@ -1063,6 +1073,9 @@ class UserRights
$oUser = self::FindUser($sLogin);
if ($oUser) {
$bRet = true;
if (!$oUser->CanBeImpersonated()) {
throw new Exception($oUser->GetName().' cannot be impersonated');
}
if (is_null(self::$m_oRealUser)) {
// First impersonation
self::$m_oRealUser = self::$m_oUser;