Exemple #1
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->email = $this->email;
         $user->phone = $this->phone;
         $user->type = $this->type;
         $user->status = User::STATUS_WAIT;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         $user->generateEmailConfirmToken();
         if ($user->save()) {
             Yii::$app->mailer->compose(['text' => 'confirmEmail'], ['user' => $user])->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name])->setTo($this->email)->setSubject('Email confirmation for ' . Yii::$app->name)->send();
         }
         return $user;
     }
     return null;
 }