In case the identifier is not specified it takes default Environment from the
list of the available for current User.
public getDefaultEnvironment ( integer $envId ) : Scalr_Environment | ||
$envId | integer | optional The identifier of the Environment |
return | Scalr_Environment | Returns Environment object |
public function xLoginAsAction() { if ($this->getParam('accountId')) { $account = new Scalr_Account(); $account->loadById($this->getParam('accountId')); $user = $account->getOwner(); } else { $user = new Scalr_Account_User(); $user->loadById($this->getParam('userId')); } if ($user->status != User::STATUS_ACTIVE) { throw new Exception('User account has been deactivated. You cannot login into it.'); } Scalr_Session::create($user->getId(), $this->user->getId()); try { $envId = $this->getEnvironmentId(true) ?: $user->getDefaultEnvironment()->id; } catch (Exception $e) { $envId = null; } $this->auditLog("user.auth.login", $user, $envId, $this->request->getRemoteAddr(), $this->user->getId()); $this->response->success(); }