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);
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue