|
|
|
@ -7643,9 +7643,16 @@ function api_get_default_tool_setting($tool, $setting, $defaultValue) |
|
|
|
|
*/ |
|
|
|
|
function api_can_login_as($loginAsUserId, $userId = null) |
|
|
|
|
{ |
|
|
|
|
$loginAsUserId = (int) $loginAsUserId; |
|
|
|
|
|
|
|
|
|
if (empty($loginAsUserId)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (empty($userId)) { |
|
|
|
|
$userId = api_get_user_id(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($loginAsUserId == $userId) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
@ -7654,10 +7661,6 @@ function api_can_login_as($loginAsUserId, $userId = null) |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($loginAsUserId != strval(intval($loginAsUserId))) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Check if the user to login is an admin |
|
|
|
|
if (api_is_platform_admin_by_id($loginAsUserId)) { |
|
|
|
|
// Only super admins can login to admin accounts |
|
|
|
@ -7677,7 +7680,7 @@ function api_can_login_as($loginAsUserId, $userId = null) |
|
|
|
|
$userList = []; |
|
|
|
|
if (is_array($users)) { |
|
|
|
|
foreach ($users as $user) { |
|
|
|
|
$userList[] = $user['user_id']; |
|
|
|
|
$userList[] = $user['id']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (in_array($loginAsUserId, $userList)) { |
|
|
|
|