public function testAuthenticate()
 {
     $user = new Person();
     $user->setUsername($this->testUsername);
     $user->setPassword($this->testPassword);
     $this->assertTrue($user->authenticate($this->testPassword));
 }
 /**
  * Attempts to authenticate users based on AuthenticationMethod
  */
 public function login()
 {
     if (isset($_POST['username'])) {
         try {
             $person = new Person($_POST['username']);
             if ($person->authenticate($_POST['password'])) {
                 $_SESSION['USER'] = $person;
                 header('Location: ' . $this->return_url);
                 exit;
             } else {
                 throw new \Exception('invalidLogin');
             }
         } catch (\Exception $e) {
             $_SESSION['errorMessages'][] = $e;
         }
     }
     $this->template->blocks[] = new Block('loginForm.inc', array('return_url' => $this->return_url));
 }
 /**
  * Attempts to authenticate users based on AuthenticationMethod
  */
 public function login(array $params)
 {
     if (isset($_POST['username'])) {
         try {
             $person = new Person($_POST['username']);
             if ($person->authenticate($_POST['password'])) {
                 $_SESSION['USER'] = $person;
                 header('Location: ' . $this->return_url);
                 exit;
             } else {
                 throw new \Exception('invalidLogin');
             }
         } catch (\Exception $e) {
             $_SESSION['errorMessages'][] = $e;
         }
     }
     return new \Application\Views\Login\LoginView(['return_url' => $this->return_url]);
 }