我設立路由,允許以下路徑:Symfony2的:使用前綴與登錄路由
/client_a/dashboard/
/client_b/dashboard/
我用我app/config/routing.yml
前綴,看起來像這樣:
AcmeMainBundle:
resource: "@AcmeMainBundle/Resources/config/routing.yml"
prefix: /{client}
問題我碰到的是,登錄路由似乎與前綴有問題。下面是我在/Resources/config/routing.yml
條目,我將其導入到主路由文件:
acme_login:
pattern: /login/
defaults: {_controller: AcmeMainBundle:Main:login }
acme_login_check:
pattern: /login_check
# defaults: This is not required since the Firewall will handle this
acme_logout:
pattern: /logout/
# defaults: This is not required since the Firewall will handle this
登錄頁面顯示正常,但用戶提交的登錄頁面後,Symfony的拋出一個錯誤,指出:
Unable to find the controller for path "/client_a/login_check". Maybe you forgot to add the matching route in your routing configuration?
在我看來,Symfony2在內部安全路由方面遇到了困難,並在routing.yml中使用了前綴。
任何方法來克服這個問題?
注意:解決此問題的一種方法是更改我的routing.yml文件中的所有路由以包含{client}參數。唯一的問題是,這是一個非常廣泛的應用程序與大量的路線。使用前綴工作奇蹟,除了登錄期間的安全處理。
感謝,
JB
是的,想過重寫控制器中的默認安全層處理。雖然有很多需要深入研究,我希望依靠Symfony自己的內置功能。如果我指定'login_check'的默認控制器(請注意,登錄動作看起來工作正常),我開始得到一堆其他錯誤,因爲缺少東西。 – jbsound 2012-07-10 11:44:43