I am trying to write a plugin and I would like to know how to get User object for the currently logged in user.
In the past I have used couple of differnt user managers and two separate methods but I'd like to know if there is any specific way atlassian recommends.
public ProjectVersionManager(VersionService versionService, UserManager um, com.atlassian.jira.user.util.UserManager um1,ReleaseService service) { this.versionService = versionService; this.releaseService = service; this.um = um; this.um1=um1; } public void updateProjectVersion(long id, String name) { String username = um.getRemoteUsername(); User user = um1.getUser(username); VersionResult v = versionService.getVersionById( user, id);
}
Community moderators have prevented the ability to post new answers.
Use this:
ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
Or as thats now deprecated
ComponentAccessor.getJiraAuthenticationContext().getUser()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just to comment on this.
getLoggedInUser() is now deprecated. This question deals with the new way of getting the logged in user.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you abhijit,
Ya now i gone through the below link, and got some idea how to write or implement code.
https://developer.atlassian.com/display/DOCS/Control+access+with+SAL
Your link also helped me in understanding database and issue related things. Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Abhijit,
Can u please tell me where to write this code and how to implement. Because currently my requirement is I need following details of user to be retrieved and I want to pass that information in webitem link.
Can you please help me as soon as possible.
Regards,
Aparajita
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Aparajita,
Not sure how to pass it to web item link. But any class can use what Jobin's solution suggests. You need a class defined in the plugin and that class can access getLoggedInuser method described by Jobin.
I am sure you have looked up documentation but you can find useful information on how to write a plugin here:
https://developer.atlassian.com/display/JIRADEV/JIRA+Developer+Documentation
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If your action is implementing JiraWebActionsupport - then http://docs.atlassian.com/jira/latest/com/atlassian/jira/web/action/JiraWebActionSupport.html#getLoggedInUser() is the easier one.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This works for the Webwork Action class. I was looking for something that uses the REST service.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.