1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-11 09:22:40 +01:00
phorge-phorge/src/applications/people/view/PhabricatorUserLogView.php
epriestley 3f5a55fa6e Let users review their own account activity logs
Summary:
Ref T4398. This adds a settings panel for account activity so users can review activity on their own account. Some goals are:

  - Make it easier for us to develop and support auth and credential information, see T4398. This is the primary driver.
  - Make it easier for users to understand and review auth and credential information (see T4842 for an example -- this isn't there yet, but builds toward it).
  - Improve user confidence in security by making logging more apparent and accessible.

Minor corresponding changes:

  - Entering and exiting hisec mode is now logged.
  - This, sessions, and OAuth authorizations have moved to a new "Sessions and Logs" area, since "Authentication" was getting huge.

Test Plan:
  - Viewed new panel.
  - Viewed old UI.
  - Entered/exited hisec and got prompted.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4398

Differential Revision: https://secure.phabricator.com/D8871
2014-04-27 17:32:09 -07:00

95 lines
2.1 KiB
PHP

<?php
final class PhabricatorUserLogView extends AphrontView {
private $logs;
private $handles;
private $searchBaseURI;
public function setSearchBaseURI($search_base_uri) {
$this->searchBaseURI = $search_base_uri;
return $this;
}
public function setLogs(array $logs) {
assert_instances_of($logs, 'PhabricatorUserLog');
$this->logs = $logs;
return $this;
}
public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles;
return $this;
}
public function render() {
$logs = $this->logs;
$handles = $this->handles;
$viewer = $this->getUser();
$action_map = PhabricatorUserLog::getActionTypeMap();
$base_uri = $this->searchBaseURI;
$rows = array();
foreach ($logs as $log) {
$ip = $log->getRemoteAddr();
$session = substr($log->getSession(), 0, 6);
if ($base_uri) {
$ip = phutil_tag(
'a',
array(
'href' => $base_uri.'?ip='.$log->getRemoteAddr().'#R',
),
$ip);
$session = phutil_tag(
'a',
array(
'href' => $base_uri.'?sessions='.$log->getSession().'#R',
),
$session);
}
$action = $log->getAction();
$action_name = idx($action_map, $action, $action);
$rows[] = array(
phabricator_date($log->getDateCreated(), $viewer),
phabricator_time($log->getDateCreated(), $viewer),
$action_name,
$log->getActorPHID()
? $handles[$log->getActorPHID()]->getName()
: null,
$handles[$log->getUserPHID()]->getName(),
$ip,
$session,
);
}
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
pht('Date'),
pht('Time'),
pht('Action'),
pht('Actor'),
pht('User'),
pht('IP'),
pht('Session'),
));
$table->setColumnClasses(
array(
'',
'right',
'wide',
'',
'',
'',
'n',
));
return $table;
}
}