I have the next security.yml:
security:
encoders:
Test\BackEndBundle\Entity\User:
algorithm: sha512
encode-as-base64: true
iterations: 10
providers:
main:
entity: { class: TestBackEndBundle:User, property: username }
firewalls:
main:
pattern: /.*
form_login:
check_path: _security_check
login_path: _security_login
default_target_path: homepage
logout: true
security: true
anonymous: true
access_control:
- { path: ^/service, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: /.*, roles: {ROLE_PARTNER, ROLE_ADMIN} }
And the next routing:
homepage:
pattern: /
defaults: { _controller: TestBackEndBundle:Default:index }
_security_login:
pattern: /login
defaults: { _controller: TestBackEndBundle:Security:login }
_security_check:
pattern: /login_check
_security_logout:
pattern: /logout
Authentication works well, instead of redirection after login. Application redirects to /_wdt/5044c6f2a329c. How can I make redirect to the home page? Thanks.
The solution is to unprotect your _wdt route.
You get this behaviour because your _wdt route is protected. When a page loads the toolbar from the _wdt route, it triggers the login. Your login form will try to redirect back to the route that triggered the login: In this case _wdt.
Add this to your access_control in security.yml
- { path: ^/_wdt, roles: 'IS_AUTHENTICATED_ANONYMOUSLY' }
This will let the toolbar work in both protected and unprotected pages, and if the page is protected, it will be the page the one who triggers the login form = it will work as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With