jeudi 30 octobre 2014

Magento Login _forward method failing


Vote count:

0




I am trying to get Magento to log me in through a form I built by using the _forward() method used to pass info to the proper controller. However, this is not working. I can't tell if the correct data is getting passed to the controller. By logging my variables, I can see that the data is there (username, hashed password, if the account actually exists, etc.). By the Magento documentation, I am calling the method properly, with the correct parameters.


Is there a step I am missing?


Here is my code and how it works:



function customerLogin()
{
var email = jQuery('#login-email').val();
var password = jQuery('#login-password').val();
jQuery.post("orderkickoff/login/login", { 'login[username]': email, 'login[password]': password } );
}


This is jQuery on the front end that gets the email and the password and then posts that information to MY controller. By setting break points, I can see that my controller is getting called properly, and the data is there.


class Namespace_OrderKickoff_LoginController extends Mage_Core_Controller_Front_Action {



public function loginAction()
{
//if customer is not logged in
if(!Mage::getSingleton('customer/session')->isLoggedIn())
{

// get the email and load the customer by id
$login = $this->getRequest()->getPost('login');
$email = $login['username'];
$customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email);
$quote = Mage::getSingleton('checkout/cart')->getQuote();

//If the customer exists, log them in by forwarding to loginPost
if($customer->getId())
{
// just make the customer log in
$mysession = Mage::getSingleton('customer/session');
$mysession->setBeforeAuthUrl(Mage::getUrl('customer/account/index'));
$mysession->setAfterAuthUrl(Mage::getUrl('customer/account/index'));
$this->_forward('loginPost','account','customer');
}
else
{
Mage::log("There is no customer with that email");
}
}

$this->_redirect('customer/account/index');
return;
}


}


This is my controller that you can see gets the customers session, and then attempts to forward the data to the controller AccountController and call the loginPost function in order to log the user in.


This is where the process is failing. I step through everything and return to my function, but nothing happens. There is no redirect, the page just stays there. I can't figure out why this is not logging me in and then redirecting me.


Can anyone tell me what I am doing wrong?


Let me know if you need any more information.


Thanks!



asked 3 mins ago

Pete

21






Magento Login _forward method failing

Aucun commentaire:

Enregistrer un commentaire