How to redirect from login action if session for user role is ready to install in symfony 2

I am developing a web application in symfony2. I have implemented login and logout using basic symfony2 security.

I used the user interface for authentication / authorization.

Now I want to check the condition in the login action if the user is all ready to log in and then redirected to the user panel.

Can anyone suggest me how to do this?

+4
source share
1 answer

Here is one way to do this:

public function loginAction() { if ($this->get('security.context')->isGranted('ROLE_USER')) { return $this->redirect($this->generateUrl('dashboard')); } } 
+2
source

Source: https://habr.com/ru/post/1389627/


All Articles