User and Roles

Hi guys,

I am developing an small application for practice. But I am unable to login the screen of specific user with the assign role.

See the attached .oml

Send me an updated .oml of my application.

EPES.oml

Solution

I think you are not passing the userid. You need to pass the user id of the logged user to get the role. Try to debug and check if you are getting any data.

Do this and let me know if it worked. After you do log in, you will get the user id using the getUserId().

Kind Reagrds,

Márcio


Hi Rohan,


I'm fine in data action get role and I notice that you are not assigning a value to your userId variable.



This variable could be an input, because every time you request that function it will ask you for an id or work it internally.


I share my two possible solutions and you decide which one favors you more.

In this solution by default we will only have the role of the logged in user.


The other solution will be to create an action on the server that asks for the id and returns the role.


so that we could do it on the server, let's say you have an administrator role that wants to query the role of a userId. or it is more you have an administrator role that can change the role for the tests.


I hope it helps you, greetings.

Solution

I think you are not passing the userid. You need to pass the user id of the logged user to get the role. Try to debug and check if you are getting any data.

Do this and let me know if it worked. After you do log in, you will get the user id using the getUserId().

Kind Reagrds,

Márcio

In addition: you always need to provide per page, the roles which can access that page.
Checking Anonymous will check àll roles, the user doesn't even have to be logged in.
Checking Registered is just for users with an account within your environment (but not specific roles).
Checking one or multiple other checkboxes, then only users with at least one of the checked roles can access the page.

Also: please don't use a switch statement like this:

Only the first condition that validates to true, will be executed. So, in the case when the user has the 'Admin' role, only the first condition will be checked.

When the user has the 'Employee' role, the 3rd condition is true.

In Short:

1) You need to check the boxes in front of the roles in all pages within the MainFlow to set the accessibility for users with those roles.

2) You can do something like this to provide a default 'landing page' for specific roles:


Hi Rohan,


I'm fine in data action get role and I notice that you are not assigning a value to your userId variable.



This variable could be an input, because every time you request that function it will ask you for an id or work it internally.


I share my two possible solutions and you decide which one favors you more.

In this solution by default we will only have the role of the logged in user.


The other solution will be to create an action on the server that asks for the id and returns the role.


so that we could do it on the server, let's say you have an administrator role that wants to query the role of a userId. or it is more you have an administrator role that can change the role for the tests.


I hope it helps you, greetings.

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