Exemplo n.º 1
0
 /**
  * Регистрация пользователя
  *
  * @return User|null сохранить модель или null при ошибке сохранения
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         $user->save();
         return $user;
     }
     return null;
 }
Exemplo n.º 2
0
 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->username = $this->username;
         $user->phone = $this->phone;
         $this->password = rand(100000, 999999);
         //Yii::$app->security->generateRandomString(6);
         $user->setTempPassword($this->password);
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             return $user;
         } else {
             die($user);
         }
     }
     return null;
 }