示例#1
0
 public function authenticateUser(User $user)
 {
     $userCookie = new User_Cookie(App::$config['APP_SHORT_NAME'], App::$config['APP_SECRET_KEY']);
     // step 1: do we have a
     if ($userCookie->isReturningUser()) {
         try {
             $userFromCookie->retrieve(App::$config['DB'], $userCookie->id);
             if ($userCookie->authenticateUser($user)) {
                 $user->setFields($userFromCookie->getData());
                 // tell the routing engine that the user
                 // is logged in
                 App::$conditions->loggedIn = true;
                 return true;
             }
         } catch (Datastore_E_RetrieveFailed $e) {
             // user does not exist in the database
             // nuke the cookie
             $userCookie->forgetUser();
         }
     }
     return false;
 }