Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
Hi, you can try to use the current user hash variable Hash Variable#CurrentUserHashVariable. Hash variables are processed server side.
Thank you, Anders I am trying in a external application to use #variables should i import the jars related to joget services. if possible kindly share an example of the same.
if you are doing from an external application then you would need to call the JSON API like previously. For security you can make the call from the server side instead of using client side javascript.
Thanks for the response I am trying the same below is the code for the same, but its returning roleAnonymous public static String getSessionUsername() { String userName = "roleAnonymous"; String url = "/jw/web/json/workflow/currentUsername"; try { URL obj = new URL(url); System.out.println("before Setting Connection Properties"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestProperty("Host", "localhost:8880"); con.setRequestProperty("Referer", "http://localhost:8880/themeinsight/";); // con.setRequestProperty("Cookie","helpGuide=false; JSESSIONID=C84DA81369DB5FE7498E8654F9F8628C"); con.setRequestMethod("GET"); int responseCode = con.getResponseCode(); System.out.println("\nSending 'GET' request to URL : " + url); System.out.println("Response Code : " + responseCode); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); // printin System.out.println("Response ---------------> " + response); JSONObject myresponse = new JSONObject(response.toString()); System.out.println("base -" + myresponse.getString("username")); } catch (Exception e) { System.out.println(e.getMessage()); } return userName; }
I have tried to get the username via the URL '/jw/web/json/workflow/currentUsername' since this is done via client script might overwritten via browser console.
kindly assits me to get the logged username from server side