How can i check the customer is confirmed or not before login.
this is my login function :
public function loginAction() {
if ($this->getRequest()->isPost()) {
$session = $this->_getSession();
if (Mage::getSingleton ( 'customer/session' )->isLoggedIn ()) {
$session->logout ();
}
$username = Mage::app ()->getRequest ()->getParam ( 'username' );
$password = Mage::app ()->getRequest ()->getParam ( 'password' );
try {
if ($session->getCustomer()->getIsJustConfirmed()) {
if (!$session->login ( $username, $password )) {
echo json_encode(array('status' => 'error','message'=> $this->__('wrong username or password.')));
exit;
} else {
echo json_encode(array('status' => 'success','message'=>$this->statusAction ()));
exit;
}
}else {
echo 'bla bla bla';
}
} catch ( Mage_Core_Exception $e ) {
switch ($e->getCode ()) {
case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED :
//$value = Mage::helper ( 'customer' )->getEmailConfirmationUrl ( $username );
$message = Mage::helper ( 'customer' )->__ ( 'This account is not confirmed.');
echo json_encode ( array (
'status' => 'error',
'message' => $this->__($message )
) );
break;
case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD :
$message = $e->getMessage ();
echo json_encode ( array (
'status' => 'error',
'message' => $this->__($message )
) );
break;
default :
$message = $e->getMessage ();
echo json_encode ( array (
'status' => 'error',
'message' => $this->__($message )
) );
}
}
}
}
iv'e used $session->getCustomer()->getIsJustConfirmed()
but it's not working.
how can i fixe it ?
$session->login($username, $password); if ($session->getCustomer()->getCustomerActivated()) { echo 'confirmed'; }else { echo 'not confirmed'; }