Customize roles from database

Hi all, I am using table user account and role from my database (without system table). I can not check roles for user after login.  Anyone can help me with this? Thank you. 



Hello Chung,

   1. Are you using the system roles like this?


 2. Or using the roles added in your database like this?


Hi Gowtham,

I am using option 2.

Thanks,

Chung Lam

Hi Chung Lam,

By using option 2 you will not be able to use any of the built-in role-based features of the Platform. That means if you want to check roles you will have to create a relationship entity between your users entity and your roles entity, and use joins to determine if a certain user has a certain role.

Although in some circumstances your approach may be needed, in most cases it is strongly advisable to use the built-in Role-based authorisation system

Hi Chung,

     1. To do this you have to create two entities like Roles(static entity) and RolesAssignes(normal entity) like this.


     2. Once the user is created, Create roleassignes record with UserId as the created UserId and RoleId as anyone of the roles in the static entity.

     3. Now to check whether the user has the specific role or not, call an aggrergate in the page with two tables joined using the RoleId as below.


     4. Now use the filter as 

SyntaxEditor Code Snippet

RoleAssigned.RoleId = Entities.Roles.CEO(Use the role you want)


     5. In the OnAfterFetch action of this aggreagte do the following 


     6. That's it.


     Hope this helps.


Thanks,

Gowtham