21
Views
3
Comments
Solved
How can I send the user to specific pages with roles from the database?

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?

2023-09-28 14-21-55
Daryna Kravets
Solution

Hi Kemal,

you need to refresh your aggregate after DoLogin action, otherwise it keeps data from the moment it was fetched. 

UserImage.jpg
Kemal Ozdogan

ohh wow i was almost there without even knowing it hahaha, thank you :D


2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

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


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.