/**
  * Attempt to authenticate the current user.
  *
  * @return object User object if successful, PEAR_Error otherwise.
  * @access public
  */
 public function authenticate()
 {
     $username = $_POST['username'];
     $password = $_POST['password'];
     if ($username == '' || $password == '') {
         $user = new PEAR_Error('authentication_error_blank');
     } else {
         $user = new User();
         $user->username = (isset($configArray['Site']['institution']) ? $configArray['Site']['institution'] . ':' : '') . $username;
         $user->password = $password;
         if (!$user->find(true)) {
             $user = new PEAR_Error('authentication_error_invalid');
         } else {
             $user->authMethod = 'Database';
             $user->last_login = date('Y-m-d H:i:s');
             $user->update();
         }
     }
     return $user;
 }