Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conduit/method/ConduitAPI_conduit_connect_Method.php
Show First 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | if ($token && $signature) { | ||||
date('r', $now), | date('r', $now), | ||||
($token - $now), | ($token - $now), | ||||
$threshold)); | $threshold)); | ||||
} | } | ||||
$valid = sha1($token.$user->getConduitCertificate()); | $valid = sha1($token.$user->getConduitCertificate()); | ||||
if ($valid != $signature) { | if ($valid != $signature) { | ||||
throw new ConduitException('ERR-INVALID-CERTIFICATE'); | throw new ConduitException('ERR-INVALID-CERTIFICATE'); | ||||
} | } | ||||
$session_key = id(new PhabricatorAuthSessionEngine()) | $session_key = id(new PhabricatorAuthSessionEngine())->establishSession( | ||||
->establishSession( | |||||
PhabricatorAuthSession::TYPE_CONDUIT, | PhabricatorAuthSession::TYPE_CONDUIT, | ||||
$user->getPHID()); | $user->getPHID(), | ||||
$partial = false); | |||||
} else { | } else { | ||||
throw new ConduitException('ERR-NO-CERTIFICATE'); | throw new ConduitException('ERR-NO-CERTIFICATE'); | ||||
} | } | ||||
return array( | return array( | ||||
'connectionID' => $connection->getID(), | 'connectionID' => $connection->getID(), | ||||
'sessionKey' => $session_key, | 'sessionKey' => $session_key, | ||||
'userPHID' => $user->getPHID(), | 'userPHID' => $user->getPHID(), | ||||
); | ); | ||||
} | } | ||||
} | } |