簡體   English   中英

Symfony 2。 未攔截轉發到login_check in

[英]Symfony2. Forwarding to login_check in isn't interceipted

我想在注冊后驗證用戶身份。

所以registrationAction是:

public function registrationAction(Request $request) {
    //Creating user...

    return $this->forward('AcmeFrontBundle:Mobile:securityCheck', array(
        '_username' => $customer->getEmail(),
        '_password' => 'pwd',
    ));
}

問題在於,Symfony安全系統不會攔截該重定向,而是直接執行securityCheckAction ,它自然是空的。

重定向以這種方式工作:

    return $this->redirect($this->generateUrl('mobile_login_check') . "?_username=" . $customer->getEmail() . "&_password=pass");

轉發是可取的,因為我想將POST請求用於registrationActionsecurityCheckAction

有任何想法嗎?

另一方面,也許最好由我自己對用戶進行身份驗證? 就像這里描述的一樣: http : //symfony.com/doc/current/cookbook/testing/simulating_authentication.html

你有什么意見?

嘗試使用POST執行重定向不是一個好主意。 原因如下: https : //softwareengineering.stackexchange.com/questions/99894/why-doesnt-http-have-post-redirect

最好的方法是創建令牌並發出登錄事件: 如何以編程方式登錄/驗證用戶?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM