示例#1
0
 public static function TheUserLoginCorrectly($params)
 {
     $model = ApiParams::checkRequiredParams($params, ApiParams::$REQUIRED_LOGIN_PARAMS);
     if ($model->errors) {
         return $model;
     } else {
         $new_model = RecipientMobileLogin::getUserByDeviceID($params[ApiParams::DEVICE_ID]);
         if (!$new_model) {
             $new_model = RecipientMobileLogin::getUserByCode($params[ApiParams::USER_CODE]);
             if ($new_model && $new_model->checkUserPassword($params[ApiParams::USER_PASSWORD])) {
                 if ($new_model->firstTimeConnection()) {
                     $new_model->setDeviceId($params[ApiParams::DEVICE_ID]);
                     return $model;
                 } else {
                     $model->addError(RecipientMobileLogin::DEVICE_ID, $error = 'you register with another device');
                     return $model;
                 }
             } else {
                 $model->addError(RecipientMobileLogin::DEVICE_ID, $error = Validation::DEVICE_ID_ERROR_MESSAGE);
                 return $model;
             }
         }
         $model = $new_model;
         $model = self::checkloginParams($model, $params);
         return $model;
     }
 }