Hello, i am new to outsystems and i am trying to make a action that check's if the user is admin or not. This is only a school project so it isn't gonna get published in anyway. Now i have these 2 databases:
i can't edit User and that's why i made a new table with the userRole and connected that to the User table.
Now i made a aggregate in my login page where i get the Admin status (true or false) of the specific user with the use of UserId and tried to implement this in my Login action. Here is a closer look to the aggregate:
And this is my action:
I am not getting any error's in any kind of way, but when i try it out. My admin user is not getting redirected to the admin page. It automatically goes to the main page, how can i fix this?
Hi Kemal,
you need to refresh your aggregate after DoLogin action, otherwise it keeps data from the moment it was fetched.
ohh wow i was almost there without even knowing it hahaha, thank you :D
Hi,
I think your complete solution should be reconsidered. OutSystems already provide entities for Role and User Role, you should NOT create them yourself. Both entities can be added to your module referencing them from the System component.
These are populated with the Users and their assigned roles in the Users application. The available roles are derived from the Roles that you can create on the Logic tab, and assign to screens.
The following documentation also shows how you can grant roles programmatically and how you can validate if a user has a specific role:
Regards,
Daniel