Exemplo n.º 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;
 }
Exemplo n.º 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;
     }
 }
 public function forcePopulate($formData)
 {
     //Populate the form elements with data retrieved from the datasource, unless
     //the user has provided new datas.
     //        $auth = Zend_Auth::getInstance();
     //        $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer'));
     //        $session = $auth->getStorage()->read();
     $session = new Zend_Session_Namespace('referencing_global');
     $customerManager = new Manager_Referencing_Customer();
     $customer = $customerManager->getCustomer($session->customerId);
     if (empty($formData['personal_title'])) {
         $formData['personal_title'] = $customer->getTitle();
     }
     if (empty($formData['first_name'])) {
         $formData['first_name'] = $customer->getFirstName();
     }
     if (empty($formData['last_name'])) {
         $formData['last_name'] = $customer->getLastName();
     }
     if (empty($formData['property_postcode'])) {
         $formData['property_postcode'] = $customer->getPostCode();
     }
     if (empty($formData['telephone_day'])) {
         $formData['telephone_day'] = $customer->getTelephone(Model_Core_Customer::TELEPHONE1);
     }
     if (empty($formData['fax_number'])) {
         $formData['fax_number'] = $customer->getFax();
     }
     if (empty($formData['telephone_evening'])) {
         $formData['telephone_evening'] = $customer->getTelephone(Model_Core_Customer::TELEPHONE2);
     }
     if (empty($formData['email'])) {
         $formData['email'] = $customer->getEmailAddress();
     }
     $postcode = new Manager_Core_Postcode();
     $addresses = $postcode->getPropertiesByPostcode($formData['property_postcode']);
     $filterString = $customer->getAddressLine(1);
     $addressList = array();
     $addressID = 0;
     foreach ($addresses as $address) {
         $addressList[$address['id']] = $address['singleLineWithoutPostcode'];
         $cleanAddress = str_replace(",", "", $address['singleLineWithoutPostcode']);
         if (stripos($cleanAddress, $filterString) === 0) {
             $addressID = $address['id'];
         }
     }
     // Add some validation
     $property_address = $this->getElement('property_address');
     $property_address->setMultiOptions($addressList);
     $validator = new Zend_Validate_InArray(array('haystack' => array_keys($addressList)));
     $validator->setMessages(array(Zend_Validate_InArray::NOT_IN_ARRAY => 'Insured address does not match with postcode'));
     $property_address->addValidator($validator, true);
     // Set the address to selected
     $property_address->setValue($addressID);
     //Allow Zend to complete the population process.
     $this->populate($formData);
     $this->property_address->setValue($addressID);
 }
 /**
  * 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;
 }
 /**
  * Executes checks when the user is a PLL finalizing an email-link-to-tenant.
  *
  * @param Zend_Controller_Request_Abstract $request
  * @param string $customerToken
  * @param string $refNo
  *
  * @return boolean
  */
 protected function _privateLandlordLinkPreDespatch(Zend_Controller_Request_Abstract $request, $customerToken, $refNo)
 {
     $session = new Zend_Session_Namespace('referencing_global');
     $referenceManager = new Manager_Referencing_Reference();
     $reference = $referenceManager->getReference($refNo);
     //Check the validity of the access.
     $params = Zend_Registry::get('params');
     $hashingString = $params->pll->emailLink->security->securityString;
     $leeWay = $params->pll->emailLink->security->securityTokenTimeLeewayUser;
     $securityManager = new Application_Core_Security($hashingString, true, $leeWay);
     $securityCheck = $securityManager->authenticate($customerToken, array('refNo', 'customerId'));
     if ($securityCheck['result']) {
         //Ensure the customer identifier extracted from the $customerToken matches the identifier
         //stored in the reference.
         $customerId = $securityCheck['data']['customerId'];
         if ($customerId != $reference->customer->customerId) {
             $session->security->error = 'Customer identifier does not match';
             return false;
         }
     } else {
         // Something went wrong, eg, hash didn't match or time was out of bounds
         $session->security->error = $securityCheck['error'];
         return false;
     }
     //Log the customer in.
     $customerManager = new Manager_Referencing_Customer();
     $customer = $customerManager->getCustomer($customerId);
     $loginManager = new Manager_Referencing_Login();
     $loginManager->logUserIn($customer->getEmailAddress(), $customer->getPassword());
     //Set the relevant session variables so that the PLL can proceed the reference.
     $session->referenceId = $reference->internalId;
     $session->productName = $reference->productSelection->product->key;
     $session->userType = Model_Referencing_ReferenceUserTypes::PRIVATE_LANDLORD;
     $session->customerToken = $customerToken;
     $session->refNo = $refNo;
     return true;
 }