More in this section
Forums / Developing with Sitefinity / Getting user roles with JavaScript

Getting user roles with JavaScript

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
4 posts, 1 answered
  1. Josh
    Josh avatar
    7 posts
    Registered:
    13 Oct 2015
    09 Dec 2015
    Link to this post

    Hi,

    I am doing some JavaScript development for a page, and I need to do conditional logic based on the group the current user belongs to. How would I get all of the user roles through JavaScript?

     

    Thanks.

  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    09 Dec 2015 in reply to Josh
    Link to this post

    You could...

    1) Create a service to return the roles, run your code in the callback of it

    2) You could create a widget for your masterpage, mvc layout, or just the page that this code needs to run, would render out the roles wherever you want and then your script has access to that.

     

    ?

  3. Josh
    Josh avatar
    7 posts
    Registered:
    13 Oct 2015
    09 Dec 2015 in reply to Steve
    Link to this post

    Steve said:

    1) Create a service to return the roles, run your code in the callback of it

    This would work, but where do I supply my current user information?

    Steve said:

    2) You could create a widget for your masterpage, mvc layout, or just the page that this code needs to run, would render out the roles wherever you want and then your script has access to that.

    Is this using the Sitefinity web designer or Visual Studio? I'm not able to get Sitefinity Thunder working in my environment.

  4. Josh
    Josh avatar
    7 posts
    Registered:
    13 Oct 2015
    14 Dec 2015 in reply to Josh
    Link to this post
    Went with a third option. Made a cookie that stored the relevant information of my user's roles, and I'm pulling from that.
    Answered
4 posts, 1 answered