I have an issue with Symfony authentification.
My security.yml file looks like this :
providers:
corebundle_admin:
entity:
class: CoreAdminBundle:Admin
property: username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
admin:
pattern: ^/admin
form_login:
provider: corebundle_admin
login_path: /admin/login
check_path: /admin/login
logout: true
anonymous: true
access_control:
- { path: ^/admin/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin, role: ROLE_ADMIN }
And my controller :
/**
* @Route("/login")
* @Method("GET")
*/
public function loginAction() {
return $this->render('CoreAdminBundle:Admin:login.html.twig');
}
/**
* @param Request $request
*
* @Route("/login")
* @Method("POST")
*/
public function checkAction(Request $request) {
// do something
}
Everything works fine, but when i'm trying to send a POST request to /admin/login, the response is a 302 and redirects to /admin/login ...
I'm stuck here, any help will be appreciated.
Thanks
change your login check action to : /login_check or any name expect '/login' it will work
/**
* @Route("/login")
* @Method("GET")
*/
public function loginAction() {
return $this->render('CoreAdminBundle:Admin:login.html.twig');
}
/**
* @param Request $request
*
* @Route("/login_check")
* @Method("POST")
*/
public function checkAction(Request $request) {
// do something
}
edit your security.yml
provider: corebundle_admin
login_path: /admin/login
check_path: /admin/login_check
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.