0
我正在研究magento的ajax登錄,並且在處理ssl時遇到了一個小問題。Magento Ajax登錄 - 通過SSL
我用來顯示我的登錄視圖的請求頁面是一個不安全的頁面。在此頁面中,我使用ajax發佈到安全網址(https://client.devserver/customer/account/ajaxLoginPost/)。我回來的json響應是正確的,但是當我刷新頁面時,用戶未登錄。
我已經在非安全站點上測試了此功能,並且按預期工作。當我添加下一層SSL時,它似乎只會中斷。
任何幫助,這是非常感謝。
這裏是我的控制器的代碼。
public function ajaxLoginPostAction()
{
if ($this->_getSession()->isLoggedIn()) {
$this->_redirect('*/*/');
return;
}
$session = $this->_getSession();
if ($this->getRequest()->isPost()) {
$login = $this->getRequest()->getPost('login');
if (!empty($login['username']) && !empty($login['password'])) {
try {
$session->login($login['username'], $login['password']);
if ($session->getCustomer()->getIsJustConfirmed()) {
$this->_welcomeCustomer($session->getCustomer(), true);
}
$messages = array("isAuthed" => true);
} catch (Mage_Core_Exception $e) {
switch ($e->getCode()) {
case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
$message = $e->getMessage();
break;
default:
$message = $e->getMessage();
}
$messages = array("isAuthed" => false, "userName" => $login['username'],"error"=> $message);
} catch (Exception $e) {
// Mage::logException($e); // PA DSS violation: this exception log can disclose customer password
}
} else {
$messages = array("isAuthed" => false, "userName" => $login['username'],"error"=>'Login and password are required.');
}
}
//$this->_loginPostRedirect();
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($messages));
}
我不明白這可以「工作」,因爲您的AJAX請求是明文的,即易於閱讀且不安全。這是您嘗試保護的用戶/密碼,而不是會話數據。 –