Example #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;
 }
 /**
  * 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;
 }