简体   繁体   中英

Create route without path [Symfony3]

In security.yml in firewall/main/form_login I have this:

default_target_path: after_login
always_use_default_target_path: true

I want to create a route named after_login, but without a path, but symfony redirects me to homepage after login.

/**
 * @Route(name="after_login")
 */
public function afterloginAction()

I want to nobody have access to this controller's method.

Is it possible to create such route or maybe another way to redirect after login to this method?

I want to add some variables to session but only once after login.

Best way approaching this would be listen on the security.interactive_login event:

default_target_path is not meant for that. That is just an redirect to an controller action, the user profile for example.

Using an controller action once and then make it not-accessible by setting a session key would be an ugly hack.

Read https://symfony.com/doc/current/components/security/authentication.html#authentication-events for that purpose. Using an event listener would make it hidden form the outside world automatically.

This is not possible with @Route. Is there wrong something here, why you want it?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM