Пример #1
0
 private function getModel()
 {
     if (!$this->isGuest && $this->_model === null) {
         $this->_model = Entrance::model()->findByPk($this->id, array('select' => 'status'));
     }
     return $this->_model;
 }
Пример #2
0
 public function authenticate()
 {
     $record = Entrance::model()->findByAttributes(array('name' => $this->username));
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($record->password != md5($this->password . $this->salt)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $record->id;
             $this->username = $record->name;
             $this->setState('username', $record->name);
             $this->setState('role', $record->status);
             $this->setState('picture', $record->photo);
             $this->setState('rname', $record->rname);
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }