Exposing user details to JS

27254

In our projects we are currently looking at how we can improve our solutions to be more adaptive to users, specifically looking at how we can make changes to improve the experience with say dyslexia or varying forms of colour blindness.

Now the bodge solution to this is to offer the user an option to pick from a dropdown on the site that we inject, however it'd be great if a user could specify in their profile settings these requirements and then in the JS be able to access a User object which contains their basic details along with any of these other settings such as additional requirements they have that we can catch in our code to provide those necessary changes.

So could we get:

  1. Settings in the user profile where they can include additional needs they have
  2. A user object exposed in JS that we can access this detail, along with the other basic details (name, phone, email)
  • Thomson Reuters Thomson Reuters staff member

    Ryan McDonough I think I'm missing something here... We have a User endpoint which effectively gives you the entire user object? Is that not sufficient for your use case? Did you want something different?

    You can't add custom attributes, but you could easily twist some of the preexisting ones, (i'd think under the 'about me section' in the UI, would be the most appropriate):

  • Peter Simpson So for this I'm talking about something which doesn't require calling the actual API, more than in the same way that I can access in the global scope on any page:

    I'd like to be able to access say: CurrentUser and be able to get CurrentUser.FullName CurentUser.Email

    Unless the endpoint you're talking about is a .action endpoint I can call from just standard JS without having to get an API key for the current user?
     

  • Thomson Reuters Thomson Reuters staff member

    Ryan McDonough Thanks I understand. So just an enhancement to bake a bit more detail in those global variables? Imran Aziz does this fall into your scope or is it a different team?

  • Peter Simpson Yeah exactly, having some more details about the user, their groups etc would really help when extending some functionality in HighQ.

  • Ryan McDonough, example library attached that can retrieve some user details asynchronously from within Collaborate (without using API)...this is taken from code written 5yrs ago, I had a quick test and it still seems to be working as expected. Should also be IE11 compliant (if required).

    Usage:

    
    	// user ID
    	CommunityExamples.User.getDetails(userID).then(function(details) {
    		console.log(details;
    	});
    	
    	// or encrypted user ID
    	CommunityExamples.User.getDetails(encryptedUserID).then(function(details) {
    		console.log(details;
    	});
    	
    

    Doesn't include any User Group permissions, this you'll have to infer some other way.

    Andrew

  • Andrew Quinn Thanks for that, that was the approach I was planning to take to get the basics - one of those where I'd prefer not to but needs must eh!