mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +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()) {
|
||||
|
||||
$log = PhabricatorUserLog::newLog(
|
||||
$user,
|
||||
$log = PhabricatorUserLog::initializeNewLog(
|
||||
$user,
|
||||
$user->getPHID(),
|
||||
PhabricatorUserLog::ACTION_LOGOUT);
|
||||
$log->save();
|
||||
|
||||
|
|
|
@ -185,9 +185,9 @@ final class PhabricatorAuthProviderPassword
|
|||
}
|
||||
|
||||
if (!$account) {
|
||||
$log = PhabricatorUserLog::newLog(
|
||||
$log = PhabricatorUserLog::initializeNewLog(
|
||||
null,
|
||||
$log_user,
|
||||
$log_user ? $log_user->getPHID() : null,
|
||||
PhabricatorUserLog::ACTION_LOGIN_FAILURE);
|
||||
$log->save();
|
||||
|
||||
|
|
|
@ -356,9 +356,9 @@ final class PhabricatorPeopleEditController
|
|||
|
||||
if ($request->isFormPost()) {
|
||||
|
||||
$log_template = PhabricatorUserLog::newLog(
|
||||
$log_template = PhabricatorUserLog::initializeNewLog(
|
||||
$admin,
|
||||
$user,
|
||||
$user->getPHID(),
|
||||
null);
|
||||
|
||||
$logs = array();
|
||||
|
|
|
@ -64,9 +64,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
|||
throw $ex;
|
||||
}
|
||||
|
||||
$log = PhabricatorUserLog::newLog(
|
||||
$log = PhabricatorUserLog::initializeNewLog(
|
||||
$this->requireActor(),
|
||||
$user,
|
||||
$user->getPHID(),
|
||||
PhabricatorUserLog::ACTION_CREATE);
|
||||
$log->setNewValue($email->getAddress());
|
||||
$log->save();
|
||||
|
@ -93,9 +93,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
|||
$email->save();
|
||||
}
|
||||
|
||||
$log = PhabricatorUserLog::newLog(
|
||||
$log = PhabricatorUserLog::initializeNewLog(
|
||||
$this->requireActor(),
|
||||
$user,
|
||||
$user->getPHID(),
|
||||
PhabricatorUserLog::ACTION_EDIT);
|
||||
$log->save();
|
||||
|
||||
|
@ -122,9 +122,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
|||
$user->setPassword($envelope);
|
||||
$user->save();
|
||||
|
||||
$log = PhabricatorUserLog::newLog(
|
||||
$log = PhabricatorUserLog::initializeNewLog(
|
||||
$this->requireActor(),
|
||||
$user,
|
||||
$user->getPHID(),
|
||||
PhabricatorUserLog::ACTION_CHANGE_PASSWORD);
|
||||
$log->save();
|
||||
|
||||
|
@ -161,9 +161,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
|||
throw $ex;
|
||||
}
|
||||
|
||||
$log = PhabricatorUserLog::newLog(
|
||||
$log = PhabricatorUserLog::initializeNewLog(
|
||||
$actor,
|
||||
$user,
|
||||
$user->getPHID(),
|
||||
PhabricatorUserLog::ACTION_CHANGE_USERNAME);
|
||||
$log->setOldValue($old_username);
|
||||
$log->setNewValue($username);
|
||||
|
@ -198,14 +198,14 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
|||
return $this;
|
||||
}
|
||||
|
||||
$log = PhabricatorUserLog::newLog(
|
||||
$log = PhabricatorUserLog::initializeNewLog(
|
||||
$actor,
|
||||
$user,
|
||||
$user->getPHID(),
|
||||
PhabricatorUserLog::ACTION_ADMIN);
|
||||
$log->setOldValue($user->getIsAdmin());
|
||||
$log->setNewValue($admin);
|
||||
|
||||
$user->setIsAdmin($admin);
|
||||
$user->setIsAdmin((int)$admin);
|
||||
$user->save();
|
||||
|
||||
$log->save();
|
||||
|
@ -236,9 +236,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
|||
return $this;
|
||||
}
|
||||
|
||||
$log = PhabricatorUserLog::newLog(
|
||||
$log = PhabricatorUserLog::initializeNewLog(
|
||||
$actor,
|
||||
$user,
|
||||
$user->getPHID(),
|
||||
PhabricatorUserLog::ACTION_SYSTEM_AGENT);
|
||||
$log->setOldValue($user->getIsSystemAgent());
|
||||
$log->setNewValue($system_agent);
|
||||
|
@ -275,14 +275,14 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
|||
return $this;
|
||||
}
|
||||
|
||||
$log = PhabricatorUserLog::newLog(
|
||||
$log = PhabricatorUserLog::initializeNewLog(
|
||||
$actor,
|
||||
$user,
|
||||
$user->getPHID(),
|
||||
PhabricatorUserLog::ACTION_DISABLE);
|
||||
$log->setOldValue($user->getIsDisabled());
|
||||
$log->setNewValue($disable);
|
||||
|
||||
$user->setIsDisabled($disable);
|
||||
$user->setIsDisabled((int)$disable);
|
||||
$user->save();
|
||||
|
||||
$log->save();
|
||||
|
@ -314,9 +314,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
|||
return $this;
|
||||
}
|
||||
|
||||
$log = PhabricatorUserLog::newLog(
|
||||
$log = PhabricatorUserLog::initializeNewLog(
|
||||
$actor,
|
||||
$user,
|
||||
$user->getPHID(),
|
||||
PhabricatorUserLog::ACTION_APPROVE);
|
||||
$log->setOldValue($user->getIsApproved());
|
||||
$log->setNewValue($approve);
|
||||
|
@ -382,9 +382,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
|||
$email->delete();
|
||||
}
|
||||
|
||||
$log = PhabricatorUserLog::newLog(
|
||||
$log = PhabricatorUserLog::initializeNewLog(
|
||||
$actor,
|
||||
$user,
|
||||
$user->getPHID(),
|
||||
PhabricatorUserLog::ACTION_DELETE);
|
||||
$log->save();
|
||||
|
||||
|
@ -435,9 +435,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
|||
throw $ex;
|
||||
}
|
||||
|
||||
$log = PhabricatorUserLog::newLog(
|
||||
$log = PhabricatorUserLog::initializeNewLog(
|
||||
$actor,
|
||||
$user,
|
||||
$user->getPHID(),
|
||||
PhabricatorUserLog::ACTION_EMAIL_ADD);
|
||||
$log->setNewValue($email->getAddress());
|
||||
$log->save();
|
||||
|
@ -480,9 +480,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
|||
|
||||
$email->delete();
|
||||
|
||||
$log = PhabricatorUserLog::newLog(
|
||||
$log = PhabricatorUserLog::initializeNewLog(
|
||||
$actor,
|
||||
$user,
|
||||
$user->getPHID(),
|
||||
PhabricatorUserLog::ACTION_EMAIL_REMOVE);
|
||||
$log->setOldValue($email->getAddress());
|
||||
$log->save();
|
||||
|
@ -536,9 +536,9 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
|
|||
$email->setIsPrimary(1);
|
||||
$email->save();
|
||||
|
||||
$log = PhabricatorUserLog::newLog(
|
||||
$log = PhabricatorUserLog::initialieNewLog(
|
||||
$actor,
|
||||
$user,
|
||||
$user->getPHID(),
|
||||
PhabricatorUserLog::ACTION_EMAIL_PRIMARY);
|
||||
$log->setOldValue($old_primary ? $old_primary->getAddress() : null);
|
||||
$log->setNewValue($email->getAddress());
|
||||
|
|
|
@ -431,9 +431,9 @@ final class PhabricatorUser
|
|||
}
|
||||
}
|
||||
|
||||
$log = PhabricatorUserLog::newLog(
|
||||
$this,
|
||||
$log = PhabricatorUserLog::initializeNewLog(
|
||||
$this,
|
||||
$this->getPHID(),
|
||||
PhabricatorUserLog::ACTION_LOGIN);
|
||||
$log->setDetails(
|
||||
array(
|
||||
|
|
|
@ -35,9 +35,9 @@ final class PhabricatorUserLog extends PhabricatorUserDAO {
|
|||
protected $remoteAddr;
|
||||
protected $session;
|
||||
|
||||
public static function newLog(
|
||||
public static function initializeNewLog(
|
||||
PhabricatorUser $actor = null,
|
||||
PhabricatorUser $user = null,
|
||||
$object_phid,
|
||||
$action) {
|
||||
|
||||
$log = new PhabricatorUserLog();
|
||||
|
@ -46,15 +46,8 @@ final class PhabricatorUserLog extends PhabricatorUserDAO {
|
|||
$log->setActorPHID($actor->getPHID());
|
||||
}
|
||||
|
||||
if ($user) {
|
||||
$log->setUserPHID($user->getPHID());
|
||||
} else {
|
||||
$log->setUserPHID('');
|
||||
}
|
||||
|
||||
if ($action) {
|
||||
$log->setAction($action);
|
||||
}
|
||||
$log->setUserPHID((string)$object_phid);
|
||||
$log->setAction($action);
|
||||
|
||||
return $log;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue