Browse Source

[FrameworkBundle] added a way to configure the logout paths

Fabien Potencier 14 năm trước cách đây
mục cha
commit
71228b5f29

+ 8 - 0
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/SecurityExtension.php

@@ -204,6 +204,14 @@ class SecurityExtension extends Extension
         // Logout listener
         if (array_key_exists('logout', $firewall)) {
             $listeners[] = new Reference('security.logout_listener');
+
+            if (isset($firewall['logout']['path'])) {
+                $container->setParameter('security.authentication.form.logout_path', $firewall['logout']['path']);
+            }
+
+            if (isset($firewall['logout']['target'])) {
+                $container->setParameter('security.authentication.form.target_path', $firewall['logout']['target']);
+            }
         }
 
         // Authentication listeners

+ 2 - 0
src/Symfony/Bundle/FrameworkBundle/Resources/config/security.xml

@@ -27,6 +27,7 @@
         <parameter key="security.authentication.form.login_path">/login</parameter>
         <parameter key="security.authentication.form.check_path">/login_check</parameter>
         <parameter key="security.authentication.form.logout_path">/logout</parameter>
+        <parameter key="security.authentication.form.target_path">/</parameter>
         <parameter key="security.authentication.listener.form.class">Symfony\Component\HttpKernel\Security\Firewall\UsernamePasswordFormAuthenticationListener</parameter>
         <parameter key="security.authentication.listener.options">
             <parameter key="login_path">%security.authentication.form.login_path%</parameter>
@@ -116,6 +117,7 @@
         <service id="security.logout_listener" class="%security.logout_listener.class%">
             <argument type="service" id="security.context" />
             <argument>%security.authentication.form.logout_path%</argument>
+            <argument>%security.authentication.form.target_path%</argument>
         </service>
 
         <service id="security.channel_listener" class="%security.channel_listener.class%">