public function up() { $users = $this->getUsers(); foreach ($users as $user) { $model = new SignupForm(); $model->attributes = $user; $model->signup(); } }
public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { if ($user = $model->signup()) { if (Yii::$app->getUser()->login($user)) { return $this->goHome(); } } } return $this->render('signup', ['model' => $model]); }
public function actionSignup() { $model = new SignupForm(); $modelInfo = new UserInfo(); if ($model->load(Yii::$app->request->post()) && $modelInfo->load(Yii::$app->request->post())) { $modelInfo->username = $model->username; if (($user = $model->signup()) && $modelInfo->save()) { // if (Yii::$app->getUser()->login($user)) { // return $this->goHome(); // } return $this->render('hint', ['hint' => '注册成功,请联系信息技术中心激活账号,然后才能访问系统!']); } else { if ($user) { $user->delete(); // exit('注册失败,请联系管理员解决问题或者仔细检查输入信息'); } } } return $this->render('signup', ['model' => $model, 'modelInfo' => $modelInfo]); }
/** * sign up api * @return type */ public function actionSignup() { $request = \Yii::$app->request; $data = $request->_get(); $model = new SignupForm(); if ($model->load($data, '')) { if ($user = $model->signup()) { if (\Yii::$app->getUser()->login($user)) { return ['code' => 0, 'msg' => '注册成功']; } } } $errors = $model->getErrors(); $error = ''; foreach ($errors as $v) { if ($v[0]) { $error = $v[0]; } } return ['code' => 1, 'msg' => $error]; }
/** * Регистрация пользователя. * * @return string */ public function actionSignup() { $this->layout = 'single'; if (!\Yii::$app->user->isGuest) { $this->goHome(); } $model = new SignupForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { $company = new Company(); if (!$company->save()) { // Невозможно создать компанию. $this->redirect('/signup'); } // Установка дефолтных типов отказов от заявки. $defaultRefuseTypesLead = new DefaultRefuseTypesLeadInstallEvent(); $defaultRefuseTypesLead->setCompanyId($company->getCompanyId()); $this->trigger(self::EVENT_SIGNUP, $defaultRefuseTypesLead); $user = $model->signup($company->getCompanyId()); if (Yii::$app->getUser()->login($user)) { return \Yii::$app->getResponse()->redirect('/'); } } return $this->render('signup', ['model' => $model]); }
/** * Show signup for guest to register on site while Option::get('allow_signup') is true. * * @return string|\yii\web\Response */ public function actionSignup() { // Change layout and body class of register-page $this->layout = 'blank'; Yii::$app->params['bodyClass'] = 'register-page'; $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { if ($user = $model->signup()) { if (Yii::$app->getUser()->login($user)) { return $this->goHome(); } } } return $this->render('signup', ['model' => $model]); }
public function actionSignup() { $this->layout = 'login'; $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { if ($user = $model->signup()) { $this->redirect(Yii::$app->urlManager->createAbsoluteUrl('site/login')); } } return $this->render('signup', ['model' => $model]); }