Exemplo n.º 1
0
 /**
  * @return Users
  */
 public static function getModel()
 {
     $model = self::$model;
     if (empty($model)) {
         $model = Users::model()->getUserById(Yii::app()->user->id);
         self::$model = $model;
     }
     return self::$model;
 }
Exemplo n.º 2
0
 public function authUser($username, $pwd)
 {
     $record = WebUser::model()->find('(LOWER(u_name)=?) and u_status=?', array(strtolower($username), Constants::USER_APPROVAL));
     if ($record === null) {
         return false;
     } else {
         if ($record->u_password == md5($pwd)) {
             return array('id' => $record->u_id, 'name' => $record->u_name, 'qid' => $record->u_qid, 'group' => $record->u_group);
         } else {
             return false;
         }
     }
 }
 function actionAuthWebUser()
 {
     header('Content-type: application/json');
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     if (IjoyPlusServiceUtils::validateUserID()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::USER_ID_INVALID);
         return;
     }
     $name = Yii::app()->request->getParam("name");
     $pwd = Yii::app()->request->getParam("pwd");
     if (!isset($name) || is_null($name)) {
         IjoyPlusServiceUtils::exportServiceError(Constants::PARAM_IS_INVALID);
         return;
     }
     if (!isset($pwd) || is_null($pwd)) {
         IjoyPlusServiceUtils::exportServiceError(Constants::PARAM_IS_INVALID);
         return;
     }
     $webUser = WebUser::model()->authUser($name, $pwd);
     if ($webUser === false) {
         IjoyPlusServiceUtils::exportServiceError(Constants::OBJECT_NOT_FOUND);
         return;
     } else {
         IjoyPlusServiceUtils::exportEntity($webUser);
     }
 }