private function _createInvitationCode()
 {
     do {
         $randStr = \common\helpers\CommonHelper::randString();
         if (InvitationCode::findOne(['invitation_code' => $randStr]) === null) {
             return $randStr;
         }
     } while (true);
 }
Пример #2
0
 /**
  * 合并参数
  * @param string $mobile
  * @param string $code
  * @return mixed
  */
 private function _paramMerge($mobile, $code)
 {
     $_param['zone'] = $this->zone;
     //appkey
     if (!is_string($this->appkey) || $this->appkey === '') {
         throw new InvalidParamException('Param for appkey error');
     } else {
         $_param['appkey'] = $this->appkey;
     }
     //手机号
     if (!\common\helpers\CommonHelper::isMobile($mobile)) {
         throw new InvalidParamException('Param for mobile error: ' . $mobile);
     } else {
         $_param['phone'] = $mobile;
     }
     //code
     if (empty($code)) {
         throw new InvalidParamException('Param for code error: ' . $code);
     } else {
         $_param['code'] = $code;
     }
     return $_param;
 }
Пример #3
0
 /**
  * 检查手机号的合法性
  * @param $mobile
  * @return bool|int
  */
 public function checkMobile($mobile)
 {
     //判断手机号是否被注册
     if (UserModel::findOne(['mobile' => $mobile]) !== NULL) {
         return ErrorConstant::USER_MOBILE_IS_EXISTS;
     }
     //判断手机号格式是否正确
     if (empty($mobile) || \common\helpers\CommonHelper::isMobile($mobile) === false) {
         return ErrorConstant::MOBILE_FORMAT_ERROR;
     }
     return true;
 }
Пример #4
0
<?php

return ['id' => 'app-backend', 'basePath' => dirname(__DIR__), 'controllerNamespace' => 'backend\\controllers', 'bootstrap' => ['log'], 'language' => 'zh_cn', 'modules' => [], 'components' => ['user' => ['identityClass' => 'common\\models\\User', 'enableAutoLogin' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'urlManager' => ['enablePrettyUrl' => true, 'showScriptName' => false], 'request' => ['class' => 'common\\compenents\\Request'], 'errorHandler' => ['errorAction' => 'site/error'], 'config' => ['ConfigPaths' => ['@backend']]], 'params' => \common\helpers\CommonHelper::loadConfig('params')];
Пример #5
0
 /**
  * 生成token算法
  * @return string
  */
 public function _createToken()
 {
     do {
         $radStr = \common\helpers\CommonHelper::randString(16);
         if (TokenModel::findOne(['token' => $radStr]) === null) {
             return $radStr;
         }
     } while (true);
 }
 /**
  * 手机号格式校验
  * @param string $mobile
  * @return bool|int
  */
 private function _checkMobile($mobile)
 {
     return \common\helpers\CommonHelper::isMobile($mobile) ? true : ErrorConstant::MOBILE_NOT_VALIDITY;
 }