示例#1
0
 public function actionActivate($code)
 {
     $row = \app\services\RegistrationDispatcher::query(['code' => $code])->one();
     if ($row === false) {
         throw new Exception('Нет такого кода или уже устарел');
     }
     $model = new NewPassword();
     $user = User::find($row['parent_id']);
     if ($model->load(Yii::$app->request->post()) && $model->update($user)) {
         Yii::$app->session->setFlash('contactFormSubmitted');
         \app\services\RegistrationDispatcher::delete($row['parent_id']);
         \Yii::$app->user->login($user);
         return $this->refresh();
     } else {
         return $this->render(['model' => $model]);
     }
     return $this->render();
 }
示例#2
0
 /**
  * Делает заказ
  *
  * @param  int $id идентификатор генератора
  *
  * @return boolean whether the model passes validation
  */
 public function insert($fieldsCols = null)
 {
     $id = $fieldsCols;
     $request = parent::insert(['beforeInsert' => function ($fields) {
         $fields['email'] = strtolower($fields['email']);
         $fields['datetime'] = time();
         $fields['status'] = \app\models\Request::STATUS_1_WAIT;
         return $fields;
     }]);
     if ($request === false) {
         return false;
     }
     $request['product_id'] = $id;
     $this->email = strtolower($this->email);
     if (!Yii::$app->user->isGuest) {
         $user = Yii::$app->user->identity;
         $request = new \app\models\Request($request);
         $request->update(['user_id' => Yii::$app->user->getId(), 'product_id' => $id]);
         // письмо клиенту
         $result = \cs\Application::mail($user->getEmail(), 'Вы сделали очередной заказ', 'next_request_client', ['user' => $user, 'request' => $request]);
     } else {
         $fields = ['email' => $this->email, 'datetime_reg' => gmdate('YmdHis'), 'is_active' => 1, 'is_confirm' => 0, 'subscribe_is_tesla' => 1, 'name_first' => $this->name, 'phone' => $this->phone];
         $user = User::insert($fields);
         $fields = \app\services\RegistrationDispatcher::add($user->getId());
         $request = new \app\models\Request($request);
         $request->update(['user_id' => $user->getId(), 'product_id' => $id]);
         // письмо им
         \cs\Application::mail($this->email, 'Поздравляем вы сделали первый шаг к своему полю коллективного счастья', 'new_request_client', ['url' => Url::to(['site/activate', 'code' => $fields['code']], true), 'user' => $user, 'request' => $request]);
     }
     foreach (\Yii::$app->params['requestMailList'] as $item) {
         // письмо нам
         $result = Application::mail($item, 'Появился заказ на TeslaGen', 'new_request', ['request' => $request, 'user' => $user]);
         //            VarDumper::dump([$result,$item]);
     }
     return $request;
 }
示例#3
0
 /**
  * Активация подписки
  *
  * @param string $code
  *
  * @return string
  * @throws Exception
  */
 public function actionActivate($code)
 {
     $row = RegistrationDispatcher::query(['code' => $code])->one();
     if ($row === false) {
         throw new Exception('Срок ссылки истек или не верный код активации');
     }
     $user = User::find($row['parent_id']);
     if (is_null($user)) {
         throw new Exception('Пользователь не найден');
     }
     $user->update(['is_active' => 1, 'is_confirm' => 1]);
     RegistrationDispatcher::delete($row['parent_id']);
     return $this->render();
 }
示例#4
0
 /**
  * Делает рассылку писем из списка рассылки
  */
 public function actionClear_registration()
 {
     \app\services\RegistrationDispatcher::cron();
 }
示例#5
0
 /**
  * Регистрирует пользователей
  *
  * @param $email
  * @param $password
  *
  * @return static
  */
 public static function registration($email, $password)
 {
     $email = strtolower($email);
     $fields = ['email' => $email, 'password' => self::hashPassword($password), 'is_active' => 0, 'is_confirm' => 0, 'datetime_reg' => gmdate('YmdHis'), 'referal_code' => Security::generateRandomString(20)];
     // добавляю поля для подписки
     foreach (\app\services\Subscribe::$userFieldList as $field) {
         $fields[$field] = 1;
     }
     \Yii::info('REQUEST: ' . \yii\helpers\VarDumper::dumpAsString($_REQUEST), 'gs\\user_registration');
     \Yii::info('Поля для регистрации: ' . \yii\helpers\VarDumper::dumpAsString($fields), 'gs\\user_registration');
     $user = self::insert($fields);
     $fields = RegistrationDispatcher::add($user->getId());
     \cs\Application::mail($email, 'Подтверждение регистрации', 'registration', ['url' => Url::to(['auth/registration_activate', 'code' => $fields['code']], true), 'user' => $user, 'datetime' => \Yii::$app->formatter->asDatetime($fields['date_finish'])]);
     return $user;
 }
示例#6
0
 /**
  * Активация регистрации
  *
  * @param string $code
  *
  * @return Response
  * @throws Exception
  */
 public function actionRegistration_activate($code)
 {
     if (\yii\helpers\ArrayHelper::getValue(Yii::$app->params, 'isTransfere', false) == true) {
         throw new Exception(Yii::$app->params['isTransfere_string']);
     }
     $row = RegistrationDispatcher::query(['code' => $code])->one();
     if ($row === false) {
         throw new Exception('Срок ссылки истек или не верный код активации');
     }
     $user = User::find($row['parent_id']);
     if (is_null($user)) {
         throw new Exception('Пользователь не найден');
     }
     $user->activate();
     Yii::$app->user->login($user);
     RegistrationDispatcher::delete($row['parent_id']);
     return $this->redirect(['site_cabinet/requests']);
 }
示例#7
0
 /**
  * Активация регистрации
  *
  * @param string $code
  *
  * @return Response
  * @throws Exception
  */
 public function actionRegistration_activate($code)
 {
     $row = RegistrationDispatcher::query(['code' => $code])->one();
     if ($row === false) {
         throw new Exception('Срок ссылки истек или не верный код активации');
     }
     $user = User::find($row['parent_id']);
     if (is_null($user)) {
         throw new Exception('Пользователь не найден');
     }
     $user->activate();
     Yii::$app->user->login($user);
     RegistrationDispatcher::delete($row['parent_id']);
     return $this->goHome();
 }
示例#8
0
文件: User.php 项目: dram1008/bogdan
 /**
  * Регистрирует пользователей
  *
  * @param $email
  * @param $password
  * @param $fields
  *
  * @return static
  */
 public static function registration($email, $password, $fields = [])
 {
     $email = strtolower($email);
     $fields = ArrayHelper::merge($fields, ['email' => $email, 'password' => self::hashPassword($password), 'is_active' => 1, 'is_confirm' => 0, 'datetime_reg' => gmdate('YmdHis'), 'referal_code' => Security::generateRandomString(20), 'subscribe_is_bogdan' => 1]);
     $user = self::insert($fields);
     $fields = \app\services\RegistrationDispatcher::add($user->getId());
     \cs\Application::mail($email, 'Подтверждение регистрации', 'registration', ['url' => Url::to(['auth/registration_activate', 'code' => $fields['code']], true), 'user' => $user, 'password' => $password, 'datetime' => \Yii::$app->formatter->asDatetime($fields['date_finish'])]);
     return $user;
 }