Differential D21869 Diff 52176 src/applications/conduit/controller/PhabricatorConduitAPIController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conduit/controller/PhabricatorConduitAPIController.php
Show First 20 Lines • Show All 284 Lines • ▼ Show 20 Lines | if ($auth_type === ConduitClient::AUTH_ASYMMETRIC) { | ||||
pht( | pht( | ||||
'Provided "%s" ("%s") is not recognized.', | 'Provided "%s" ("%s") is not recognized.', | ||||
'auth.type', | 'auth.type', | ||||
$auth_type), | $auth_type), | ||||
); | ); | ||||
} | } | ||||
$token_string = idx($metadata, 'token'); | $token_string = idx($metadata, 'token'); | ||||
if (strlen($token_string)) { | if ($token_string !== null && strlen($token_string)) { | ||||
if (strlen($token_string) != 32) { | if (strlen($token_string) != 32) { | ||||
return array( | return array( | ||||
'ERR-INVALID-AUTH', | 'ERR-INVALID-AUTH', | ||||
pht( | pht( | ||||
'API token "%s" has the wrong length. API tokens should be '. | 'API token "%s" has the wrong length. API tokens should be '. | ||||
'32 characters long.', | '32 characters long.', | ||||
$token_string), | $token_string), | ||||
▲ Show 20 Lines • Show All 376 Lines • ▼ Show 20 Lines | if ($params !== null) { | ||||
unset($params['__conduit__']); | unset($params['__conduit__']); | ||||
return array($metadata, $params, true); | return array($metadata, $params, true); | ||||
} | } | ||||
// Otherwise, look for a single parameter called 'params' which has the | // Otherwise, look for a single parameter called 'params' which has the | ||||
// entire param dictionary JSON encoded. | // entire param dictionary JSON encoded. | ||||
$params_json = $request->getStr('params'); | $params_json = $request->getStr('params'); | ||||
if (strlen($params_json)) { | if (phutil_nonempty_string($params_json)) { | ||||
$params = null; | $params = null; | ||||
try { | try { | ||||
$params = phutil_json_decode($params_json); | $params = phutil_json_decode($params_json); | ||||
} catch (PhutilJSONParserException $ex) { | } catch (PhutilJSONParserException $ex) { | ||||
throw new PhutilProxyException( | throw new PhutilProxyException( | ||||
pht( | pht( | ||||
"Invalid parameter information was passed to method '%s'.", | "Invalid parameter information was passed to method '%s'.", | ||||
$method), | $method), | ||||
▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines |