コード例 #1
0
 public function execute($filterChain)
 {
     if ($this->isFirstCall()) {
         if (!isset($_SERVER['PHP_AUTH_USER'])) {
             $this->sendHeaders();
             exit;
         }
         $user = QubitUser::checkCredentials($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'], $error);
         if (null === $user) {
             $this->sendHeaders();
             return;
         }
         $user = new myUser(new sfEventDispatcher(), new sfNoStorage());
         $user->authenticate($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
         // We'll need username/email details later
         sfContext::getInstance()->request->setAttribute('user', $user);
     }
     $filterChain->execute();
 }
コード例 #2
0
 public function authenticate($username, $password)
 {
     $authenticated = false;
     // anonymous is not a real user
     if ($username == 'anonymous') {
         return false;
     }
     $user = QubitUser::checkCredentials($username, $password, $error);
     // user account exists?
     if ($user !== null) {
         $authenticated = true;
         $this->signIn($user);
     }
     return $authenticated;
 }