Пример #1
0
 /**
  * Attempts to log the user in.
  * 
  * @param string $emailAddress The login name.
  * @param string $password The password.
  * @return bool
  */
 public function login($emailAddress, $password)
 {
     // There may be more than one customer record with the same email address.
     $loginManager = new Manager_Referencing_Login();
     // Attempt to log in using the current customer details.
     if ($loginManager->logUserIn($emailAddress, $password)) {
         // User successfully logged in. Set some session variables
         // and return success.
         $customerManager = new Manager_Referencing_Customer();
         $customer = $customerManager->getByEmailAddress($emailAddress);
         $session = new Zend_Session_Namespace('referencing_global');
         $session->customerId = $customer->getIdentifier(Model_Core_Customer::IDENTIFIER);
         return true;
     }
     return false;
 }
Пример #2
0
 /**
  * Logs-in the private landlord (PLL) referencing customer.
  *
  * @param string $emailAddress The unique customer email address
  * @param string $password The customer's password.
  * @return boolean Returns true if the user has been successfully logged in, false otherwise.
  */
 public function logUserIn($emailAddress, $password)
 {
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer'));
     $customerManager = new Manager_Referencing_Customer();
     $adapter = $customerManager->getAuthAdapter(array('email' => $emailAddress, 'password' => $password));
     $result = $auth->authenticate($adapter);
     if ($result->isValid()) {
         $customer = $customerManager->getByEmailAddress($emailAddress);
         if ($customer->getEmailValidated() !== true) {
             $auth->clearIdentity();
             return false;
         } else {
             $storage = $auth->getStorage();
             $storage->write($adapter->getResultRowObject(array('title', 'first_name', 'last_name', 'email_address', 'id')));
             return true;
         }
     } else {
         return false;
     }
 }
 /**
  * Login function to add references to the system.
  *
  * @return void
  */
 public function loginAction()
 {
     $this->view->pageTitle = 'Tenant Referencing Login';
     $loginForm = new LandlordsReferencing_Form_Login();
     // Tell page to use AJAX validation as we go
     $this->view->headScript()->appendScript('var ajaxValidate = true; var ajaxValidatePage = "login";');
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ($loginForm->isValid($request->getPost())) {
             $data = $loginForm->getValues();
             //Delegate login actions to the LoginForm.
             if ($loginForm->login($data['email'], $data['password'])) {
                 $this->_despatchToNext();
                 return;
             } else {
                 $customerManager = new Manager_Referencing_Customer();
                 $customer = $customerManager->getByEmailAddress($data['email']);
                 if (!$customer) {
                     //None of the customer records matched the details provided by the user.
                     $loginForm->setDescription("Sorry, we've been unable to find these details.\n                    \tPlease check the details you entered are correct and try again");
                 } else {
                     $loginForm->setDescription('Hello, at the moment you\'re unable to access My HomeLet  because
                     you haven\'t validated your email address yet. We\'ve sent you an email which includes a link
                     to confirm your email address and validate your My HomeLet account. If you\'ve not received
                     your validation email or if you\'re unable to access your account, please call us on 0845 117
                     6000 - we\'re always happy to help!');
                 }
             }
         }
     } else {
         $this->_setProductsToDisplay($this->getRequest());
     }
     // Set this to whatever you want the progress bar to how in percents
     $this->view->fractionComplete = 0;
     $this->view->form = $loginForm;
 }