Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15489331
D21170.id50408.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D21170.id50408.diff
View Options
diff --git a/src/applications/auth/adapter/PhutilJIRAAuthAdapter.php b/src/applications/auth/adapter/PhutilJIRAAuthAdapter.php
--- a/src/applications/auth/adapter/PhutilJIRAAuthAdapter.php
+++ b/src/applications/auth/adapter/PhutilJIRAAuthAdapter.php
@@ -10,7 +10,6 @@
private $jiraBaseURI;
private $adapterDomain;
- private $currentSession;
private $userInfo;
public function setJIRABaseURI($jira_base_uri) {
@@ -106,21 +105,34 @@
private function getUserInfo() {
if ($this->userInfo === null) {
- $this->currentSession = $this->newJIRAFuture('rest/auth/1/session', 'GET')
- ->resolveJSON();
-
- // The session call gives us the username, but not the user key or other
- // information. Make a second call to get additional information.
+ $this->userInfo = $this->newUserInfo();
+ }
- $params = array(
- 'username' => $this->currentSession['name'],
- );
+ return $this->userInfo;
+ }
- $this->userInfo = $this->newJIRAFuture('rest/api/2/user', 'GET', $params)
+ private function newUserInfo() {
+ // See T13493. Try a relatively modern (circa early 2020) API call first.
+ try {
+ return $this->newJIRAFuture('rest/api/3/myself', 'GET')
->resolveJSON();
+ } catch (Exception $ex) {
+ // If we failed the v3 call, assume the server version is too old
+ // to support this API and fall back to trying the older method.
}
- return $this->userInfo;
+ $session = $this->newJIRAFuture('rest/auth/1/session', 'GET')
+ ->resolveJSON();
+
+ // The session call gives us the username, but not the user key or other
+ // information. Make a second call to get additional information.
+
+ $params = array(
+ 'username' => $session['name'],
+ );
+
+ return $this->newJIRAFuture('rest/api/2/user', 'GET', $params)
+ ->resolveJSON();
}
public static function newJIRAKeypair() {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 12, 7:58 AM (3 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7706123
Default Alt Text
D21170.id50408.diff (1 KB)
Attached To
Mode
D21170: Use "rest/api/3/myself" to retrieve JIRA profile details, not "rest/auth/1/session"
Attached
Detach File
Event Timeline
Log In to Comment