Skip to content

Commit 4a80c85

Browse files
authored
username as default self-hosted field for current_user() (#1200)
1 parent df0d0e9 commit 4a80c85

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

jira/client.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -3846,15 +3846,15 @@ def backup_download(self, filename: str = None):
38463846
return None
38473847

38483848
def current_user(self, field: Optional[str] = None) -> str:
3849-
"""Returns the username or emailAddress of the current user. For anonymous
3850-
users it will return a value that evaluates as False.
3849+
"""Return the `accountId` (Cloud) else `username` of the current user.
3850+
For anonymous users it will return a value that evaluates as False.
38513851
38523852
Args:
38533853
field (Optional[str]): the name of the identifier field.
3854-
Defaults to "accountId" for Jira Cloud, else "key"
3854+
Defaults to "accountId" for Jira Cloud, else "username"
38553855
38563856
Returns:
3857-
str
3857+
str: User's `accountId` (Cloud) else `username`.
38583858
"""
38593859
if not hasattr(self, "_myself"):
38603860

@@ -3865,7 +3865,9 @@ def current_user(self, field: Optional[str] = None) -> str:
38653865
self._myself = r_json
38663866

38673867
if field is None:
3868-
field = "accountId" if self._is_cloud else "key"
3868+
# Note: For Self-Hosted 'displayName' can be changed,
3869+
# but 'name' and 'key' cannot, so should be identifying properties.
3870+
field = "accountId" if self._is_cloud else "name"
38693871

38703872
return self._myself[field]
38713873

0 commit comments

Comments
 (0)