Use initializeNewLog rather than instantiate the UserLog
Summary: Use initializeNewLog rather than instantiate the UserLog, Closes T4912 Test Plan: Run install-certificate Reviewers: #blessed_reviewers, btrahan Reviewed By: #blessed_reviewers, btrahan Subscribers: epriestley Maniphest Tasks: T4912 Differential Revision: https://secure.phabricator.com/D8887
This commit is contained in:
@@ -46,7 +46,7 @@ final class ConduitAPI_conduit_getcertificate_Method extends ConduitAPIMethod {
|
|||||||
60 * 5);
|
60 * 5);
|
||||||
|
|
||||||
if (count($failed_attempts) > 5) {
|
if (count($failed_attempts) > 5) {
|
||||||
$this->logFailure();
|
$this->logFailure($request);
|
||||||
throw new ConduitException('ERR-RATE-LIMIT');
|
throw new ConduitException('ERR-RATE-LIMIT');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,13 +56,13 @@ final class ConduitAPI_conduit_getcertificate_Method extends ConduitAPIMethod {
|
|||||||
trim($token));
|
trim($token));
|
||||||
|
|
||||||
if (!$info || $info->getDateCreated() < time() - (60 * 15)) {
|
if (!$info || $info->getDateCreated() < time() - (60 * 15)) {
|
||||||
$this->logFailure();
|
$this->logFailure($request, $info);
|
||||||
throw new ConduitException('ERR-BAD-TOKEN');
|
throw new ConduitException('ERR-BAD-TOKEN');
|
||||||
} else {
|
} else {
|
||||||
$log = id(new PhabricatorUserLog())
|
$log = PhabricatorUserLog::initializeNewLog(
|
||||||
->setActorPHID($info->getUserPHID())
|
$request->getUser(),
|
||||||
->setUserPHID($info->getUserPHID())
|
$info->getUserPHID(),
|
||||||
->setAction(PhabricatorUserLog::ACTION_CONDUIT_CERTIFICATE)
|
PhabricatorUserLog::ACTION_CONDUIT_CERTIFICATE)
|
||||||
->save();
|
->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,11 +79,14 @@ final class ConduitAPI_conduit_getcertificate_Method extends ConduitAPIMethod {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function logFailure() {
|
private function logFailure(
|
||||||
|
ConduitAPIRequest $request,
|
||||||
|
PhabricatorConduitCertificateToken $info = null) {
|
||||||
|
|
||||||
$log = id(new PhabricatorUserLog())
|
$log = PhabricatorUserLog::initializeNewLog(
|
||||||
->setUserPHID('-')
|
$request->getUser(),
|
||||||
->setAction(PhabricatorUserLog::ACTION_CONDUIT_CERTIFICATE_FAILURE)
|
$info ? $info->getUserPHID() : '-',
|
||||||
|
PhabricatorUserLog::ACTION_CONDUIT_CERTIFICATE_FAILURE)
|
||||||
->save();
|
->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user