How to get the username of user log in JIRA?

Oriol Esplugas August 11, 2011

Hello,

I'm new in this type of development in JIRA and I'm a little lost.

I'm trying to get the usermane of the member that is log in JIRA with JAVA code. I'm creating a customfield and I need to know this information.

¿Wich classes of JIRA I've to use?

¿Can anyone help me?

Thanks.

4 answers

1 accepted

1 vote
Answer accepted
m@
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 11, 2011

An implementation of JiraAuthenticationContext can be autowired in to any bean you define in your plugin.

Once you have a reference to an implementation of this object you can call getLoggedInUser().

See: http://docs.atlassian.com/jira/4.3.4/com/atlassian/jira/security/JiraAuthenticationContext.html

Oriol Esplugas August 11, 2011

Hello,

Thank you! I do it!

I'm working with JIRA 3.13 and the object getLoggedInUser() d0esn't exist. I use the option getUser() and I get the username of the current user.

Thanks!

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

Just to comment on this.

getLoggedInUser() is now deprecated. This question deals with the new way of getting the logged in user.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 11, 2011

Yep, that's clear. Matthew beat me to what I was about to say...

0 votes
Oriol Esplugas August 11, 2011

Sorry for my english is not good.

Yes I need the current user.

The function of the customfield is show you a list of users that are assign in a project and have the permission of Assignable. But only can see this customfield if they have the permission of Assign. This is why I need the current user to know if I have to hide the customfield or not.

¿Do you understand?

Thanks a lot

I don't know if I have explained correctly.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 11, 2011

>I'm trying to get the usermane of the member that is log in JIRA with JAVA code

Sorry, that doesn't make an sense. Do you mean you want the current user?

If that's the case, then there's several ways to do it, but it's best to use the most appropriate one for what you're doing and that can vary. What does your custom field need to do?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events