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