check if logged in user has end user role using client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2018 12:35 AM
Hi Friends,
Could someone please let me know, how can I check if logged in user has end user role using client script ?
THank you.
Rishi
- 14,002 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2018 01:08 AM
Hi Rishi,
Use hasRole(). This will return'TRUE' if the user is having any role else return 'FALSE'.
var usr = gs.getUser();
if(usr.hasRole())
{
gs.print("Yes");
}
else
{
gs.print("No");
}
Thanks,
Maddy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2018 01:26 AM
Hi Maddy,
Thanks for your quick response !
Do you think we can use gs.getUser() at client side ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2018 01:31 AM
You'll need to use the client side version for g_user, you can use g_user.hasRoles() to return true if the user has any roles. Or you can refine is with g_user.hasRole('your_role_name')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2018 02:56 AM
Hi Rishi,
Sorry i was reffering to server scripts.
You can use, g_user.hasRoles() in client script.
Thanks,
Maddy