/**
  * Performs authentication based on provided username and password
  * @param WebUser $webuser
  * @return <type>
  */
 private function _authenticate(Auth $auth)
 {
     $user = $auth->authenticate($this->username, $this->password);
     if (!$user) {
         $this->addError('password', 'Incorrect username or password');
         return false;
     } else {
         return $user;
     }
 }
 /**
  * Prepares the model for persistence
  */
 public function prepare()
 {
     if (!isset($this->Created)) {
         $this->Created = date('YmdHis', time());
     }
     if (isset($this->ConfirmPassword)) {
         unset($this->ConfirmPassword);
     }
     $this->Password = Auth::getHash($this->Password);
     //        $this->ProfileImage = $this->_processProfileImage();
 }
 /**
  * Factory method, enables dependency injection
  * @param <type> $controller
  * @param Request $request
  * @return controller
  */
 public static function factory($controller, Request $req, Response $res)
 {
     return new $controller($req, $res, Auth::factory());
 }