Beispiel #1
0
 /**
  * @operationName("users mobile binding")
  * @operationDescription("users mobile binding")
  */
 public function bindMobileAction()
 {
     $bindingForm = new MobileBindingForm(new User());
     $curUser = Login::getCurrentUser();
     $data = $this->request->getPut();
     $data['userId'] = $curUser['id'];
     if (!$bindingForm->isValid($data)) {
         return $this->showInvalidMessagesAsJson($bindingForm);
     }
     try {
         if (!User::bindMobile($data['mobile'], $data['captcha'], $data['userId'])) {
             return $this->showErrorMessageAsJson(400, 'BIND_MOBILE_FAILURE');
         }
     } catch (Exception\LogicException $e) {
         return $this->showExceptionAsJson($e);
     }
     return $this->showResponseAsJson(['mobile' => $data['mobile'], 'status' => true]);
 }