php - Redirect loop after login -
After login , I want to reach the same page. But I have a redirect loop of death
security.yml
Login: Pattern: ^ / admin / login security: false anonymous: true firewalls: dev: pattern: ^ / (_ (Profiler | wdt) | CSS | picture | js) / security: wrong protected_rea: pattern: ^ / admin form_login: check_path: _login_check login_path: _admin_login default_target_path: _admin_dashboard always_use_default_target_path: correct logout: path: _admin_logout target: _admin_login anonymous : ~ Access_control: - {path: ^ / admin / login, roles: IS_AUTHENTICATED_ANONYMOUSLY} - {path: ^ / admin, roles: [ROLE_USER, ROLE_ADMIN]}
routing.yml: < / P "@Testback Bundle / Controller / Dashboard Controller. FPP" type: annotation Pre>
Dashboard Controller Php:
> * @ Root ("/" Admin / Dashboard ") * Extension Controller of / Dashboard Controller {/ ** * @ Root (" / ", Name = "_ admin_dashboard") * @template () * / public function index () (return array);}}and SecuredController.php:
< Code> ... / ** * @ route ("/ admin") * / class protected control controller extension {/ ** * @ route ("/ login", name = "_ admin_login") * @ template () * / Public Function Login Action (Request $ Request) {If ($ Request-> Feature (SecurityContext :: AUTHENTICATION_ERROR)) {$ error = $ request- & gt; Attributes- & gt; Get (SecurityContext :: AUTHENTICATION_ERROR);} and {$ error = $ request- & gt; getSession () - & Gt; Get (SecurityContext :: AUTHENTICATION_ERROR);} return array ('last_username' = & gt; $ request- & gt; getSession () - & gt; get (SecurityContext :: LAST_USERNAME), 'Error' = & Gt; $ error,);} / ** * @ route ("/ login_check", name = "_ login_check") * / public function security connection () {// security layer will stop this request} / ** * @ Root ("/ Logout", name = "_ Admin_logout") * / Public Function Logout Not () {// security layer will block the request}}
What did I do?
This works for me, the main difference is that your protected area is ^ / admin, and I have this. ^ /
There are so many unnecessary codes, but I was tired of working for it and when I worked, I do not want to touch it anymore.
(This is in my case, I wanted
firewall: dev: pattern: ^ / (_ (profiler | wdt) | CSS | picture | js) / security: false free: Putter N : ^ / $ Security: wrong: Free login: Password: / Password_Raina: Pattern: ^ / form_login: Login_path: Login check_path: Login_check always_user_default_trage_path: true default_target_path: / borsa / ofertes logout: path: / logout target: / login: Pattern: ^ / Security: wrong Unnamed: ~ access_control: {path: ^ / login, roles: IS_AUTHENTICATED_ANONYMOUSLY} # - {path: ^ / login, roles: IS_AUTHENTICATED_ANONYMOUSLY, require_channel: https} - {path: ^ / administrator, roles: ROLE_ADMIN}
Comments
Post a Comment