DirectorActivityLog: use IP when unauthenticated

This applies mostly to self service API
This commit is contained in:
Thomas Gelf 2017-07-21 12:06:36 +02:00
parent d97022bf88
commit d92492d5a1

View File

@ -57,6 +57,10 @@ class DirectorActivityLog extends DbObject
$auth = Auth::getInstance();
if ($auth->isAuthenticated()) {
return $auth->getUser()->getUsername();
} elseif (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
return '<' . $_SERVER['HTTP_X_FORWARDED_FOR'] . '>';
} elseif (array_key_exists('REMOTE_ADDR', $_SERVER)) {
return '<' . $_SERVER['REMOTE_ADDR'] . '>';
} else {
return '<unknown>';
}