This question is in reference to Atlassian Documentation: Frequently Asked Questions
How to get current logged in user in bitbucket in javascript? Or is there any alternate way of finding logged in user in Bitbucket like we find it in JIRA by (AJS.params.loggedInUser)
Community moderators have prevented the ability to post new answers.
If you wrap you JS with define(...), you can access current user from pageState.
The following example defines more libs you might need, but it's taken from real code...
define('yout/path', ['aui', 'jquery', 'underscore', 'bitbucket/util/events', 'bitbucket/util/navbuilder', 'bitbucket/util/state', 'bitbucket/util/server', 'exports'], function (AJS, $, _, events, navBuilder, pageState, server, exports) { // your JS here // ... var currentUser = pageState.getCurrentUser(); }
I'm not shure if you need in atlassian-plugin.xml the bitbucket-web:global dependency:
<client-resource key="my-key" name="My Client Resources"> <context>atl.general</context> <directory location="/static"/> <dependency>com.atlassian.bitbucket.server.bitbucket-web:global</dependency> </client-resource>
Please hava a look also at
A full code example you will find here:
https://bitbucket.org/jheger/stash-mybranches (also at Marketplace)
Kind regards, Johannes
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.