1
votes

How to redirect a user to a page depending on the role.

For example:

There is a module hello_world, and it has an action index (it prints the text "Hello World")

There is a module user, and in it there is action userList.

The administrator can view all these actions. User can only view the hello_world page.

How to do this with security.yml files.

1
Hi! Welcome to StackOverflow. Please check link on how to ask a question. - Nick

1 Answers

2
votes

You can define security credentials for each module. If the user doesn't need a credential, then

/.../modules/hello_world/config/security.yml

all:
  is_secure: false

And

/.../modules/user/config/security.yml

all:
  is_secure: true
  credentials: [ admin ]
userList:
  credentials: [ SOME_SPECIFIC_CREDENTIALS_FOR_ACTION ]