mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 02:32:42 +01:00
Allow PhabricatorUserLog to store non-user PHIDs
Summary: Ref T4310. This is a small step toward separating out the session code so we can establish sessions for `ExternalAccount` and not just `User`. Also fix an issue with strict MySQL and un-admin / un-disable from web UI. Test Plan: Logged in, logged out, admined/de-admin'd user, added email address, checked user log for all those events. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4310 Differential Revision: https://secure.phabricator.com/D7953
This commit is contained in:
parent
49963d8e4c
commit
220d680f37
6 changed files with 38 additions and 45 deletions
|
@ -23,9 +23,9 @@ final class PhabricatorLogoutController
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
|
|
||||||
$log = PhabricatorUserLog::newLog(
|
$log = PhabricatorUserLog::initializeNewLog(
|
||||||
$user,
|
|
||||||
$user,
|
$user,
|
||||||
|
$user->getPHID(),
|
||||||
PhabricatorUserLog::ACTION_LOGOUT);
|
PhabricatorUserLog::ACTION_LOGOUT);
|
||||||
$log->save();
|
$log->save();
|
||||||
|
|
||||||
|
|
|
@ -185,9 +185,9 @@ final class PhabricatorAuthProviderPassword
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$account) {
|
if (!$account) {
|
||||||
$log = PhabricatorUserLog::newLog(
|
$log = PhabricatorUserLog::initializeNewLog(
|
||||||
null,
|
null,
|
||||||
$log_user,
|
$log_user ? $log_user->getPHID() : null,
|
||||||
PhabricatorUserLog::ACTION_LOGIN_FAILURE);
|
PhabricatorUserLog::ACTION_LOGIN_FAILURE);
|
||||||
$log->save();
|
$log->save();
|
||||||
|
|
||||||
|
|
|
@ -356,9 +356,9 @@ final class PhabricatorPeopleEditController
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
|
|
||||||
$log_template = PhabricatorUserLog::newLog(
|
$log_template = PhabricatorUserLog::initializeNewLog(
|
||||||
$admin,
|
$admin,
|
||||||
$user,
|
$user->getPHID(),
|
||||||
null);
|
null);
|
||||||
|
|
||||||
$logs = array();
|
$logs = array();
|
||||||
|
|
|
@ -64,9 +64,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
||||||
throw $ex;
|
throw $ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
$log = PhabricatorUserLog::newLog(
|
$log = PhabricatorUserLog::initializeNewLog(
|
||||||
$this->requireActor(),
|
$this->requireActor(),
|
||||||
$user,
|
$user->getPHID(),
|
||||||
PhabricatorUserLog::ACTION_CREATE);
|
PhabricatorUserLog::ACTION_CREATE);
|
||||||
$log->setNewValue($email->getAddress());
|
$log->setNewValue($email->getAddress());
|
||||||
$log->save();
|
$log->save();
|
||||||
|
@ -93,9 +93,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
||||||
$email->save();
|
$email->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
$log = PhabricatorUserLog::newLog(
|
$log = PhabricatorUserLog::initializeNewLog(
|
||||||
$this->requireActor(),
|
$this->requireActor(),
|
||||||
$user,
|
$user->getPHID(),
|
||||||
PhabricatorUserLog::ACTION_EDIT);
|
PhabricatorUserLog::ACTION_EDIT);
|
||||||
$log->save();
|
$log->save();
|
||||||
|
|
||||||
|
@ -122,9 +122,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
||||||
$user->setPassword($envelope);
|
$user->setPassword($envelope);
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
$log = PhabricatorUserLog::newLog(
|
$log = PhabricatorUserLog::initializeNewLog(
|
||||||
$this->requireActor(),
|
$this->requireActor(),
|
||||||
$user,
|
$user->getPHID(),
|
||||||
PhabricatorUserLog::ACTION_CHANGE_PASSWORD);
|
PhabricatorUserLog::ACTION_CHANGE_PASSWORD);
|
||||||
$log->save();
|
$log->save();
|
||||||
|
|
||||||
|
@ -161,9 +161,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
||||||
throw $ex;
|
throw $ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
$log = PhabricatorUserLog::newLog(
|
$log = PhabricatorUserLog::initializeNewLog(
|
||||||
$actor,
|
$actor,
|
||||||
$user,
|
$user->getPHID(),
|
||||||
PhabricatorUserLog::ACTION_CHANGE_USERNAME);
|
PhabricatorUserLog::ACTION_CHANGE_USERNAME);
|
||||||
$log->setOldValue($old_username);
|
$log->setOldValue($old_username);
|
||||||
$log->setNewValue($username);
|
$log->setNewValue($username);
|
||||||
|
@ -198,14 +198,14 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$log = PhabricatorUserLog::newLog(
|
$log = PhabricatorUserLog::initializeNewLog(
|
||||||
$actor,
|
$actor,
|
||||||
$user,
|
$user->getPHID(),
|
||||||
PhabricatorUserLog::ACTION_ADMIN);
|
PhabricatorUserLog::ACTION_ADMIN);
|
||||||
$log->setOldValue($user->getIsAdmin());
|
$log->setOldValue($user->getIsAdmin());
|
||||||
$log->setNewValue($admin);
|
$log->setNewValue($admin);
|
||||||
|
|
||||||
$user->setIsAdmin($admin);
|
$user->setIsAdmin((int)$admin);
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
$log->save();
|
$log->save();
|
||||||
|
@ -236,9 +236,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$log = PhabricatorUserLog::newLog(
|
$log = PhabricatorUserLog::initializeNewLog(
|
||||||
$actor,
|
$actor,
|
||||||
$user,
|
$user->getPHID(),
|
||||||
PhabricatorUserLog::ACTION_SYSTEM_AGENT);
|
PhabricatorUserLog::ACTION_SYSTEM_AGENT);
|
||||||
$log->setOldValue($user->getIsSystemAgent());
|
$log->setOldValue($user->getIsSystemAgent());
|
||||||
$log->setNewValue($system_agent);
|
$log->setNewValue($system_agent);
|
||||||
|
@ -275,14 +275,14 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$log = PhabricatorUserLog::newLog(
|
$log = PhabricatorUserLog::initializeNewLog(
|
||||||
$actor,
|
$actor,
|
||||||
$user,
|
$user->getPHID(),
|
||||||
PhabricatorUserLog::ACTION_DISABLE);
|
PhabricatorUserLog::ACTION_DISABLE);
|
||||||
$log->setOldValue($user->getIsDisabled());
|
$log->setOldValue($user->getIsDisabled());
|
||||||
$log->setNewValue($disable);
|
$log->setNewValue($disable);
|
||||||
|
|
||||||
$user->setIsDisabled($disable);
|
$user->setIsDisabled((int)$disable);
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
$log->save();
|
$log->save();
|
||||||
|
@ -314,9 +314,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$log = PhabricatorUserLog::newLog(
|
$log = PhabricatorUserLog::initializeNewLog(
|
||||||
$actor,
|
$actor,
|
||||||
$user,
|
$user->getPHID(),
|
||||||
PhabricatorUserLog::ACTION_APPROVE);
|
PhabricatorUserLog::ACTION_APPROVE);
|
||||||
$log->setOldValue($user->getIsApproved());
|
$log->setOldValue($user->getIsApproved());
|
||||||
$log->setNewValue($approve);
|
$log->setNewValue($approve);
|
||||||
|
@ -382,9 +382,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
||||||
$email->delete();
|
$email->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
$log = PhabricatorUserLog::newLog(
|
$log = PhabricatorUserLog::initializeNewLog(
|
||||||
$actor,
|
$actor,
|
||||||
$user,
|
$user->getPHID(),
|
||||||
PhabricatorUserLog::ACTION_DELETE);
|
PhabricatorUserLog::ACTION_DELETE);
|
||||||
$log->save();
|
$log->save();
|
||||||
|
|
||||||
|
@ -435,9 +435,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
||||||
throw $ex;
|
throw $ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
$log = PhabricatorUserLog::newLog(
|
$log = PhabricatorUserLog::initializeNewLog(
|
||||||
$actor,
|
$actor,
|
||||||
$user,
|
$user->getPHID(),
|
||||||
PhabricatorUserLog::ACTION_EMAIL_ADD);
|
PhabricatorUserLog::ACTION_EMAIL_ADD);
|
||||||
$log->setNewValue($email->getAddress());
|
$log->setNewValue($email->getAddress());
|
||||||
$log->save();
|
$log->save();
|
||||||
|
@ -480,9 +480,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
||||||
|
|
||||||
$email->delete();
|
$email->delete();
|
||||||
|
|
||||||
$log = PhabricatorUserLog::newLog(
|
$log = PhabricatorUserLog::initializeNewLog(
|
||||||
$actor,
|
$actor,
|
||||||
$user,
|
$user->getPHID(),
|
||||||
PhabricatorUserLog::ACTION_EMAIL_REMOVE);
|
PhabricatorUserLog::ACTION_EMAIL_REMOVE);
|
||||||
$log->setOldValue($email->getAddress());
|
$log->setOldValue($email->getAddress());
|
||||||
$log->save();
|
$log->save();
|
||||||
|
@ -536,9 +536,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
||||||
$email->setIsPrimary(1);
|
$email->setIsPrimary(1);
|
||||||
$email->save();
|
$email->save();
|
||||||
|
|
||||||
$log = PhabricatorUserLog::newLog(
|
$log = PhabricatorUserLog::initialieNewLog(
|
||||||
$actor,
|
$actor,
|
||||||
$user,
|
$user->getPHID(),
|
||||||
PhabricatorUserLog::ACTION_EMAIL_PRIMARY);
|
PhabricatorUserLog::ACTION_EMAIL_PRIMARY);
|
||||||
$log->setOldValue($old_primary ? $old_primary->getAddress() : null);
|
$log->setOldValue($old_primary ? $old_primary->getAddress() : null);
|
||||||
$log->setNewValue($email->getAddress());
|
$log->setNewValue($email->getAddress());
|
||||||
|
|
|
@ -431,9 +431,9 @@ final class PhabricatorUser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$log = PhabricatorUserLog::newLog(
|
$log = PhabricatorUserLog::initializeNewLog(
|
||||||
$this,
|
|
||||||
$this,
|
$this,
|
||||||
|
$this->getPHID(),
|
||||||
PhabricatorUserLog::ACTION_LOGIN);
|
PhabricatorUserLog::ACTION_LOGIN);
|
||||||
$log->setDetails(
|
$log->setDetails(
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -35,9 +35,9 @@ final class PhabricatorUserLog extends PhabricatorUserDAO {
|
||||||
protected $remoteAddr;
|
protected $remoteAddr;
|
||||||
protected $session;
|
protected $session;
|
||||||
|
|
||||||
public static function newLog(
|
public static function initializeNewLog(
|
||||||
PhabricatorUser $actor = null,
|
PhabricatorUser $actor = null,
|
||||||
PhabricatorUser $user = null,
|
$object_phid,
|
||||||
$action) {
|
$action) {
|
||||||
|
|
||||||
$log = new PhabricatorUserLog();
|
$log = new PhabricatorUserLog();
|
||||||
|
@ -46,15 +46,8 @@ final class PhabricatorUserLog extends PhabricatorUserDAO {
|
||||||
$log->setActorPHID($actor->getPHID());
|
$log->setActorPHID($actor->getPHID());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user) {
|
$log->setUserPHID((string)$object_phid);
|
||||||
$log->setUserPHID($user->getPHID());
|
|
||||||
} else {
|
|
||||||
$log->setUserPHID('');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action) {
|
|
||||||
$log->setAction($action);
|
$log->setAction($action);
|
||||||
}
|
|
||||||
|
|
||||||
return $log;
|
return $log;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue