Exemplo n.º 1
0
 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         return User::registerByPhoneNumber($this->phone, $this->username, $this->password, $this->email);
     }
     return null;
 }
Exemplo n.º 2
0
 public function actionSignUp()
 {
     if (!empty($_POST['login']) && !empty($_POST['password']) && !empty($_POST['fio'])) {
         $user = new User();
         $user->phone = $_POST['login'];
         $user->password = $_POST['password'];
         $user->username = $_POST['fio'];
         $activation_key = $user->registerByPhoneNumber($_POST['login'], $_POST['fio'], $_POST['password']);
         if ($activation_key == -1) {
             $result = ['status' => ['code' => 408, 'message' => "Пользователь с таким номером телефона уже существует"]];
         } elseif ($activation_key == -2) {
             $result = ['status' => ['code' => 405, 'message' => 'Введены неверные данные']];
         } else {
             $result = ['status' => ['code' => 200, 'message' => "ОК"], 'data' => ['activation_key' => $activation_key]];
         }
     } else {
         $result = ['status' => ['code' => 403, 'message' => 'Не все обязательные поля заполнены']];
     }
     return Json::encode($result);
 }