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(); }
/** * Активация подписки * * @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(); }
/** * Активация регистрации * * @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']); }
/** * Активация регистрации * * @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(); }