Get user roles in controllers

Hi, in my som_modules.py i want to add validate by the roles, how i can do this? how i can get the roles?

Thanks

Try frappe.get_roles() to get the roles of the current user.

5 Likes

How do we do the same in client side?
and how can we check for a specific role for logged in user in client side?

okey Found it .

frappe.user.has_role(“Role”)

5 Likes

frappe.user.has_role(“Role”) will fetch all the users with role Role? Isn’t working for me.

Just to update, it is now frappe.user_roles in “Frappe Framework: v11.1.44 (master)” version

4 Likes

frappe.user_roles.includes("<Your Role>") This will return true if the user has <Your Role> .
This will work on client side.

This is not working

Works fine for me.

1 Like

I need to get user roles in portal page.How can I get the roles in portal pages?