mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-20 13:52:40 +01:00
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:
parent
a017a8e02b
commit
08d9e5ec99
1 changed files with 13 additions and 10 deletions
|
@ -46,7 +46,7 @@ final class ConduitAPI_conduit_getcertificate_Method extends ConduitAPIMethod {
|
|||
60 * 5);
|
||||
|
||||
if (count($failed_attempts) > 5) {
|
||||
$this->logFailure();
|
||||
$this->logFailure($request);
|
||||
throw new ConduitException('ERR-RATE-LIMIT');
|
||||
}
|
||||
|
||||
|
@ -56,13 +56,13 @@ final class ConduitAPI_conduit_getcertificate_Method extends ConduitAPIMethod {
|
|||
trim($token));
|
||||
|
||||
if (!$info || $info->getDateCreated() < time() - (60 * 15)) {
|
||||
$this->logFailure();
|
||||
$this->logFailure($request, $info);
|
||||
throw new ConduitException('ERR-BAD-TOKEN');
|
||||
} else {
|
||||
$log = id(new PhabricatorUserLog())
|
||||
->setActorPHID($info->getUserPHID())
|
||||
->setUserPHID($info->getUserPHID())
|
||||
->setAction(PhabricatorUserLog::ACTION_CONDUIT_CERTIFICATE)
|
||||
$log = PhabricatorUserLog::initializeNewLog(
|
||||
$request->getUser(),
|
||||
$info->getUserPHID(),
|
||||
PhabricatorUserLog::ACTION_CONDUIT_CERTIFICATE)
|
||||
->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())
|
||||
->setUserPHID('-')
|
||||
->setAction(PhabricatorUserLog::ACTION_CONDUIT_CERTIFICATE_FAILURE)
|
||||
$log = PhabricatorUserLog::initializeNewLog(
|
||||
$request->getUser(),
|
||||
$info ? $info->getUserPHID() : '-',
|
||||
PhabricatorUserLog::ACTION_CONDUIT_CERTIFICATE_FAILURE)
|
||||
->save();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue