How to get logged in user with latest SDK?

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 2, 2013

The method getLoggedInUser() is deprecated. ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

How can i get the logged in User object?

3 answers

3 votes
MB
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 14, 2013

The correct way to do this is to use

User user = ComponentAccessor.getJiraAuthenticationContext().getUser().getDirectoryUser();

More info in this article.

0 votes
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 14, 2013

Try with the following code

try {
User projectLead=issue.getProjectObject().getProjectLead().getDirectoryUser();
issue.setAssignee(projectLead);
}

0 votes
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 2, 2013

Use getUser which returns ApplicationUser object. This is to support the renaming of users.

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 2, 2013

My existing plugin has broken because I want User object to set as assignee for issue but i cannot set ApplicationUser object. Could you please let me know how to achieve this?

User user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
try {
issue.setAssignee(issue.getProjectObject().getLead());
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events