public function actionRegister() { if (!\Yii::$app->user->isGuest) { return $this->goHome(); } $model = new RegisterForm(); $request = Yii::$app->request; $post = $request->post(); if (isset($post)) { $model->attributes = $request->post('RegisterForm'); if ($model->validate()) { //create user in DB $user = new User(); $user->username = $model->username; $user->password = $model->password; $user->no_login = 0; $user->save(); //perform login $login = new LoginForm(); $login->username = $user->username; $login->password = $user->password; $login->login(); return $this->goHome(); } } return $this->render('register', ['model' => $model]); }
public function actionRegister() { // if (!\Yii::$app->user->isGuest) { // return $this->goHome(); // } $model = new RegisterForm(); if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model, 'username'); } if ($model->load(Yii::$app->request->post())) { if ($model->validate()) { $user = new User(); $user->username = $model->username; $user->setPassword($model->password); $user->email = $model->email; $user->name = $model->name; $user->surname = $model->surname; Yii::trace($user); if ($user->save(false)) { return $this->redirect('/user/login'); } } } return $this->render('register', ['model' => $model]); }
public function actionRegister() { $model = new RegisterForm(); $model->load(Yii::$app->request->post()); if ($model->validate()) { $model->registerUser(); return $this->render('index'); } return $this->render('register', ['model' => $model]); }
public function actionRegister() { $model = new RegisterForm(); if (Yii::$app->request->isPost) { $model->load(Yii::$app->request->post()); $model->photo = UploadedFile::getInstance($model, 'photo'); $model->register(); $this->redirect(Url::to(['site/profile'])); } return $this->render('register', ['model' => $model]); }
public function actionRegister() { $m_registerForm = new RegisterForm(); if ($m_registerForm->load(Yii::$app->request->post()) && $m_registerForm->validate()) { $m_registerForm->use_auth = Yii::$app->request->post()['RegisterForm']['use_login'] . '_auth'; $m_registerForm->use_access = Yii::$app->request->post()['RegisterForm']['use_login'] . '_access'; if ($m_registerForm->save()) { Yii::$app->session->setFlash('success', 'Datos enviados correctamente.'); } } return $this->render('register', ['m_registerForm' => $m_registerForm]); }
public function actionRegister() { if (!Yii::$app->user->isGuest) { return $this->goHome(); } $model = new RegisterForm(); if ($model->load(Yii::$app->request->post()) && $model->register()) { return $this->goBack(); } else { return $this->render('register', ['model' => $model]); } }
public function actionRegister() { $this->layout = "main-login"; if (!\Yii::$app->user->isGuest) { return $this->goHome(); } $model = new RegisterForm(); if ($model->load(Yii::$app->request->post()) && $model->register()) { Yii::$app->session->addFlash("success", "Register success, please login"); return $this->redirect(["site/login"]); } return $this->render('register', ['model' => $model]); }
public function actionIndex() { if (!Yii::$app->user->isGuest) { return $this->redirect(['site/index']); } $model = new RegisterForm(); if ($model->load(Yii::$app->request->post())) { if ($model->register()) { $model->login(); return $this->redirect(['site/index']); } } return $this->render('index', ['model' => $model]); }
public function actionRegister() { $model = new RegisterForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { if ($model->register()) { return $this->goHome(); } else { Yii::$app->session->setFlash('error', 'Возникла ошибка при регистрации'); Yii::error('Ошибка при регистрации'); return $this->refresh(); } } return $this->render('register', ['model' => $model]); }
public function actionRegister() { $this->view->title = 'Регистрация'; if (!\Yii::$app->user->isGuest) { return $this->goHome(); } $model = new RegisterForm(); if ($model->load(Yii::$app->request->post())) { if ($user = $model->register()) { Yii::$app->user->login($user); return $this->goHome(); } } return $this->render('register', ['model' => $model]); }
public function actionRegister() { $user = new Account(); $model = new RegisterForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { if (isset($_POST['save'])) { $user->nickname = $model->nickname; $user->password = $model->password; $user->email = $model->email; $user->save(); return $this->redirect(array('site/user', 'id' => $user->userID)); } } return $this->render('register', ['model' => $model]); }
/** * Signs user up. * * @return Users|null the saved model or null if saving fails */ public function register() { $user = null; $transaction = Yii::$app->db->beginTransaction(); try { $group = new Groups(); $group->name = $this->email; if ($group->save()) { $user = parent::register($group->id); for ($i = 0; $i < $this->beacon_count; $i++) { $beacon = new Beacons(); $beacon->name = Yii::$app->security->generateRandomString(16); $beacon->title = "Such title {$i}"; $beacon->description = "So description {$i}"; $beacon->minor = $group->id . $user->id . $i; $beacon->major = $group->id . $user->id . $i; $beacon->place = "Wow Place {$i}"; $beacon->uuid = UUID::v4(); $beacon->groupToBind = $group->id; $beacon->save(); } } $transaction->commit(); return $user; } catch (Exception $e) { if ($transaction->isActive) { $transaction->rollBack(); } return null; } }
public function actionRegister() { if (!\Yii::$app->user->isGuest) { return $this->goHome(); } // Throw exception if there are users registered if (User::find()->active()->count()) { throw new \yii\web\BadRequestHttpException(); } $model = new RegisterForm(); if ($model->load(Yii::$app->request->post()) && $model->register()) { return $this->goBack(); } else { return $this->render('register', ['model' => $model]); } }
public function actionRegister() { $model_register_form = new RegisterForm(); //Если данные были отправлены и прошли валидацию if ($model_register_form->load(Yii::$app->request->post()) && $model_register_form->validate()) { //Если регистрация прошла успешно,данные были сохранены,авторизуем пользователя if ($user = $model_register_form->register()) { Yii::$app->user->login($user); $url = Url::toRoute(['login']); return $this->redirect($url); } else { Yii::error("Ошибка при регистрации"); var_dump($model_register_form->getErrors()); //return $this->refresh(); } } return $this->render("register", ["model" => $model_register_form]); }
public function actionRegister() { /* if (!Yii::$app->user->isGuest) { return $this->goHome(); } */ echo Yii::$app->language; $model = new RegisterForm(); if ($model->load(Yii::$app->request->post())) { if ($user = $model->register()) { if (Yii::$app->getUser()->login($user)) { return $this->goHome(); } } } return $this->render('register', ['model' => $model]); }
public function actionRegister() { $back = isset($_REQUEST['back']) ? $_REQUEST['back'] : ''; if (!is_null($this->getLoggedUser())) { if (!empty($back)) { $this->redirect($back); } else { $this->redirect(['user/profile']); } } $this->layout = 'main'; $model = new RegisterForm(); if ($model->load(Yii::$app->request->post()) && $model->register()) { StoreUtils::sendPendingEmails(); if (!empty($back)) { return $this->redirect($back); } return $this->goHome(); } return $this->render('register', ['model' => $model, 'back' => $back]); }
public function actionRegister() { if (!Yii::$app->user->isGuest) { return $this->redirect(Url::toRoute('/site/index')); } $model = new RegisterForm(); if ($model->load(Yii::$app->request->post())) { $user = $model->register(); if ($user) { $login = new LoginForm(); $login->username = $model->username; $login->password = $model->password; $login->login(); echo '<pre>'; print_r($login); echo '</pre>'; die; } return $this->goHome(); } return $this->render('register', ['model' => $model]); }
public function run() { $request = Yii::$app->getRequest(); $form = new RegisterForm(); if ($request->isPost) { $form->attributes = $request->post('RegisterForm'); $form->recaptcha_token = $request->post('recaptcha'); $form->recaptcha_response = $request->post('g-recaptcha-response'); if ($form->validate()) { $user = $form->toUserModel(); if ($user->save()) { // ログインの動きを統一するためにログインフォームで認証かける $login = new LoginForm(); $login->screen_name = $form->screen_name; $login->password = $form->password; if ($login->login()) { return $this->controller->redirect(Yii::$app->user->getReturnUrl()); } } } } return $this->controller->render('login.tpl', ['login' => new RegisterForm(), 'register' => $form]); }
public function actionRegister() { $model = new RegisterForm(); $post = Yii::$app->request->post(); $model->telephone = $post['telephone']; $model->password = $post['password']; //var_dump($model->password); $model->Register(); }
public function actionRegister() { $model = new RegisterForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { // valid data received in $model // do something meaningful here about $model ... return $this->render('profile', ['model' => $model]); } else { // either the page is initially displayed or there is some validation error return $this->render('register', ['model' => $model]); } }
public function actionRegister() { $model = new RegisterForm(); $msg = null; if ($model->load(Yii::$app->request->post()) && Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } if ($model->load(Yii::$app->request->post())) { if ($model->validate()) { $table = new User(); $table->loadDefaultValues(); $table->username = $model->username; $table->Mail = $model->Mail; $table->password = crypt($model->password, Yii::$app->params["salt"]); $table->Authkey = $this->randKey("abcdef0123456789", 200); $table->Token = $this->randKey("abcdef0123456789", 200); $table->RRHH_idRRHH = $model->RRHH_idRRHH; $table->tiporrhh_idTipoRRHH = $model->tiporrhh_idTipoRRHH; if ($table->insert()) { $user = User::find()->Where("AuthKey=:AuthKey", [":AuthKey" => $table->Authkey])->one(); $id = urlencode($user->idAutenticacion); $authKey = urlencode($user->Authkey); $subject = "Confirmar registro"; $body = "<h1>Haga click en el siguiente enlace para finalizar tu registro</h1>"; $link = Intranet::getUrlHead() . "/basic/web/index.php?r=site/confirm&id=" . $id . "&authKey=" . $authKey; $body .= "<a href='" . $link . "'>Confirmar</a>"; if (Yii::$app->params["adminEmail"] != '*****@*****.**') { Yii::$app->mailer->compose()->setTo($user->Mail)->setFrom([Yii::$app->params["adminEmail"] => Yii::$app->params["title"]])->setSubject($subject)->setHtmlBody($body)->send(); $msg = "Enhorabuena, ahora sólo falta que confirmes tu registro en tu cuenta de correo "; } else { $msg = "Confirmación alternativa " . Mailto::getUrlMailto($user->Mail, $subject, "", "", "Haga click en el siguiente enlace para finalizar tu registro", $link, "\nClick aquí para reenviar confirmación vía mailto:"); } $model->username = null; $model->Mail = null; $model->password = null; $model->password_repeat = null; } else { $msg = "Ha ocurrido un error al llevar a cabo tu registro\n" . "username="******"\npassword="******"\nemail=" . $model->Mail . "\n\n\t\t\t\t\tidRRHH=" . $model->RRHH_idRRHH . "\nidTipoRrhh=" . $model->tiporrhh_idTipoRRHH; } } else { $model->getErrors(); } } $subModelTiporrhh = new Tiporrhh(); $subModelRrhh = new Rrhh(); return $this->render("register", ["model" => $model, "msg" => $msg, "subModelTiporrhh" => $subModelTiporrhh, "subModelRrhh" => $subModelRrhh]); }