i need to have 2 login form.
1 -> main site 2 -> my backend
i have see many thread for this.
I try to do it, but i have an error : "You must configure the check path to be handled by the firewall using form_login in your security firewall configuration."
But it's set in security.yml
My route is ok, my form is ok, and i don't see where is my error.
This is my security.yml
admin_login:
context: backend
pattern: ^/th-admin/login
anonymous: true
admin_check:
context: backend
pattern: ^/th-admin/login_check
anonymous: true
admin_access_denied:
context: backend
pattern: ^/th-admin/access_denied
anonymous: true
admin:
context: backend
pattern: ^/th-admin
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
#use_referer: true # this is not needed if you always use default target
#always_use_default_target_path: true
#default_target_path: th_admin_dashboard
login_path: th_admin_login
check_path: th_admin_check
logout:
path: th_admin_logout
target: th_admin_login
anonymous: false
access_denied_url: th_admin_denied
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
login_path: fos_user_security_login
check_path: fos_user_security_check
logout: true
anonymous: true
access_control:
- { path: ^/, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/th-admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/th-admin/access_denied, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/th-admin/, role: ROLE_ADMIN }
This is my fos_user configuration :
fos_user:
db_driver: orm
firewall_name: main
user_class: TH\UserBundle\Entity\User
This is my custom form :
{% if error %}
<div>{{ error.messageKey|trans(error.messageData, 'security') }}</div>
{% endif %}
<form class="m-t" role="form" method="post" action="{{ path("th_admin_check") }}">
<input type="hidden" name="_csrf_token" value="{{ csrf_token }}" />
<div class="form-group">
<input name="_username" value="{{ last_username }}" type="email" class="form-control" placeholder="{{ 'admin.login.email'|trans }}" required="">
</div>
<div class="form-group">
<input name="_password" type="password" class="form-control" placeholder="{{ 'admin.login.password'|trans }}" required="">
</div>
<input type="hidden" name="_submit" value="Login" />
<button type="submit" class="btn btn-primary block full-width m-b">{{ 'admin.login.login'|trans }}</button>
</form>
This is my routes :
th_admin_denied:
path: /access_denied
defaults: { _controller: THAdminBundle:Default:accessDenied }
th_admin_login:
path: /login
defaults: { _controller: FOSUserBundle:Security:login }
th_admin_check:
path: /login_check
defaults: { _controller: FOSUserBundle:Security:check }
th_admin_logout:
path: /logout
defaults: { _controller: FOSUserBundle:Security:logout }
th_admin_dashboard:
path: /
defaults: { _controller: THAdminBundle:Dashboard:index }
I have try to clear cache, hard clear cache (empty folder with rm -rf)
When i set the other check url, this work but this go to the main firewall. The main firewall work. But my admin backend firewall doesn't work...
Anyone know where is my error ?
Thx