Пример #1
0
 public function checkAction()
 {
     $username = $this->request->get('username');
     $email = $this->request->get('email');
     if ($username) {
         $userinfo = Models\Login::findFirst(array("username = '******'"));
     } elseif ($email) {
         $userinfo = Models\Login::findFirst(array("email = '{$email}'"));
     } else {
         $userinfo = array();
     }
     $this->view->disable();
     if ($userinfo) {
         $this->response->setStatusCode('409', 'User Already Exists');
     }
     return $this->response->setJsonContent(array('exist' => $userinfo ? true : false, 'id' => $userinfo ? $userinfo->id : 0, 'status' => $userinfo ? $userinfo->status : null));
 }
Пример #2
0
 /**
  * @param $mobile
  * @param $captcha
  * @param $userId
  * @return bool
  * @throws Exception\InvalidArgumentException
  * @throws Exception\UnauthorizedException
  */
 public static function bindMobile($mobile, $captcha, $userId)
 {
     /** @var Login $user */
     $user = Login::findFirst('id=' . $userId);
     if (!$user) {
         throw new Exception\UnauthorizedException('ERR_USER_NOT_EXIST');
     }
     if (!$user->mobileCaptchaCheck($mobile, $captcha)) {
         throw new Exception\InvalidArgumentException('ERR_USER_MOBILE_CAPTCHA_CHECK_FAILED');
     }
     $user->mobile = $mobile;
     $user->mobileStatus = 'active';
     $user->mobileConfirmedAt = time();
     $saved = $user->save();
     $user->login();
     return $saved;
 }
Пример #3
0
 public function checkAction()
 {
     $username = $this->request->get('username');
     $email = $this->request->get('email');
     $mobile = $this->request->get('mobile');
     if ($this->hasQQ($username)) {
         $this->response->setStatusCode('409', 'User Already Exists');
     }
     $loginedUser = Models\Login::getCurrentUser();
     $extraCondition = '';
     // 已登录用户表示当前为修改用户名,允许与当前用户名相同
     if ($loginedUser['id'] > 0) {
         $extraCondition .= ' AND id != ' . $loginedUser['id'];
     }
     if ($username) {
         $userinfo = Models\Login::findFirst(array("username = '******' {$extraCondition}"));
     } elseif ($email) {
         $userinfo = Models\Login::findFirst(array("email = '{$email}' {$extraCondition}"));
     } elseif ($mobile) {
         $userinfo = Models\Login::findFirst(array("mobile = '{$mobile}' {$extraCondition}"));
     } else {
         $userinfo = array();
     }
     $this->view->disable();
     if ($userinfo) {
         $this->response->setStatusCode('409', 'User Already Exists');
     }
     return $this->response->setJsonContent(array('exist' => $userinfo ? true : false, 'id' => $userinfo ? $userinfo->id : 0, 'status' => $userinfo ? $userinfo->status : null));
 }