Пример #1
0
 /**
  * Authenticates a user.
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = wUsers::model()->find('LOWER(username)=?', array(strtolower($this->username)));
     //var_dump($user); exit();
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!$user->validatePassword($this->password, Yii::app()->params->hashkey)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $user->id;
             $this->_group_id = $user->group;
             $this->username = $user->username;
             //$this->setState('role',$user->group_id);
             $this->errorCode = self::ERROR_NONE;
             //update login
         }
     }
     return $this->errorCode == self::ERROR_NONE;
 }
Пример #2
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = wUsers::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }