public function actionSignup() { if (!\Yii::$app->user->isGuest) { if (Yii::$app->user->identity->role >= 5) { $modelsmanager = Users::find()->where(['role' => 5])->select(['id', 'username'])->all(); $arraymanager = array(); foreach ($modelsmanager as $modelmanager) { $arraymanager[$modelmanager->id] = $modelmanager->username; } $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { if ($model->id_manager == NULL) { $model->id_manager = 0; if (Yii::$app->user->identity->role == 5) { $model->id_manager = Yii::$app->user->identity->id; } } if ($model->role == NULL) { $model->role = 1; } if ($user = $model->signup()) { Yii::$app->session->setFlash('info', 'Пользователь создан.'); return $this->redirect(['users']); } } return $this->render('signup', ['model' => $model, 'arraymanager' => $arraymanager]); } else { Yii::$app->session->setFlash('error', 'У вас не прав доступа к этому разделу сайта.'); return $this->redirect(['index']); } } else { return $this->redirect(['login']); } }
public function actionLogin() { $endDate = \app\models\Weeks::END_DATE; if (date('Y-m-d') > $endDate) { return $this->render('unavailable', ['endDate' => $endDate]); } if (!\Yii::$app->user->isGuest) { return $this->AddEssay(); } if (Yii::$app->request->isAjax && Yii::$app->request->get('sendCodePhone')) { return $this->sendCodePhone(Yii::$app->request->get('sendCodePhone')); } elseif (Yii::$app->request->isAjax && Yii::$app->request->get('checkCode') && Yii::$app->request->get('phone')) { return $this->checkCode(Yii::$app->request->get('phone'), Yii::$app->request->get('checkCode')); } $signupForm = new SignupForm(); if ($signupForm->load(Yii::$app->request->post()) && $signupForm->signup()) { return $this->AddEssay('register'); } $loginForm = new LoginForm(); if ($loginForm->load(Yii::$app->request->post()) && $loginForm->login()) { if (Yii::$app->user->identity->isModerator() || Yii::$app->user->identity->isClient()) { return $this->redirect(["/admin/index"]); } else { return $this->AddEssay('login'); } } return $this->render('login', ['loginForm' => $loginForm, 'signupForm' => $signupForm]); }
public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post()) && $model->signup()) { return $this->goHome(); } return $this->render('signup', ['model' => $model]); }
public function actionSignup() { $register = new SignupForm(); if ($register->load(YII::$app->request->post()) && $register->signup()) { return YII::$app->response->redirect(['login/login']); } else { return $this->render('signup', ['model' => $register]); } }
/** * User sign-up method. * @return array */ public function actionSignup() { $model = new SignupForm(new User()); if ($model->load(\Yii::$app->getRequest()->getBodyParams(), '') && ($user = $model->signup())) { return ['auth_token' => $user->getAuthKey(), 'success' => true, 'user' => $user]; } else { return ['message' => implode(' ', $model->getFirstErrors()), 'success' => false]; } }
public function actionSignups() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { $user = $model->signup(); if ($user && Yii::$app->getUser()->login($user)) { return $this->goHome(); } } return $this->render('signup', ['model' => $model]); }
/** * @return \yii\web\Response */ public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { if ($user = $model->signup()) { Yii::$app->getSession()->setFlash('success', Yii::t("app/signup", "Check your email for further instructions.")); return $this->refresh(); } } return $this->render('signup', ['model' => $model]); }
public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { if ($user = $model->signup()) { Yii::$app->getSession()->setFlash('success', 'Подтвердите ваш электронный адрес.'); return $this->goHome(); } } return $this->render('signup', ['model' => $model]); }
public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { if ($user = $model->signup()) { Yii::$app->session->setFlash('success', 'Account is created. Now you can sign in.'); return $this->goHome(); } } return $this->render('signup', ['model' => $model]); }
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->redirect(['/subscriber/index']); } } } return $this->render('signup', ['model' => $model]); }
public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { if ($user = $model->signup()) { return $this->render('login', ['model' => new LoginForm()]); } else { return $this->goHome(); } } return $this->render('signup', ['model' => $model]); }
/** * РЕГИСТРАЦИЯ * @return string|\yii\web\Response */ public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { if ($user = $model->signup()) { if (Yii::$app->getUser()->login($user, 3600 * 24 * 90)) { //$this->mailSingup(Yii::$app->request->post()['SignupForm']); return $this->goHome(); } } } return $this->render('signup', ['model' => $model]); }
public function actionSignup() { $model = new SignupForm(); $authItems = AuthItem::find()->all(); 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, 'authItems' => $authItems]); }
public function actionCreate() { $response = ['success' => false, 'errors' => [], 'data' => []]; $model = new SignupForm(); $post = $model->load(['SignupForm' => Yii::$app->request->post()]); if ($user = $model->signup()) { $response['data'] = $user; $response['success'] = true; } else { $response['errors'] = $model->getErrors(); } return $response; }
public function actionSignup() { $this->checkAccess($this->id); $model = new SignupForm(); if ($model->load(Yii::$app->request->post(), '')) { if ($user = $model->signup()) { $response = Yii::$app->getResponse(); $response->setStatusCode(201); return true; } } throw new ServerErrorHttpException('Failed to sign up for unknown reason.'); }
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(); } } } Yii::$app->layout = 'cover'; return $this->render('index', ['model' => $model]); }
/** * Register new user * * @return array * @throws \yii\base\InvalidConfigException * @throws \yii\web\BadRequestHttpException */ public function actionRegister() { $model = new SignupForm(); if ($model->load(Yii::$app->getRequest()->getBodyParams(), '')) { if ($user = $model->signup()) { return ['access_token' => $user->access_token]; } else { Yii::$app->response->setStatusCode(406); return $model->errors; } } else { throw new \yii\web\BadRequestHttpException(); } }
/** * User signup. * @return mixed */ public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { $user = $model->signup(); if ($user !== null) { if (Yii::$app->user->login($user)) { Yii::$app->session->setFlash('success', 'ユーザ登録が完了いたしました。'); return $this->goHome(); } } } return $this->render('signup', ['model' => $model]); }
public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { if ($user = $model->signup()) { $profile = new Profile(); if ($profile->initProfile($model, $user->id)) { if (Yii::$app->getUser()->login($user)) { return $this->goHome(); } } } } return $this->render('signup', ['model' => $model]); }
public function actionRegister() { $model = new SignupForm(); //$model->scenario = 'short_register'; if (Yii::$app->request->isAjax && Yii::$app->request->isPost) { if ($model->load(Yii::$app->request->post())) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } } if ($model->load(Yii::$app->request->post()) && $model->signup()) { Yii::$app->session->setFlash('success', 'Success register'); } return $this->render('register', ['model' => $model]); }
/** * Creates a new User model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { if ($model->signup()) { Yii::$app->session->setFlash('success', 'Добавлен новый пользователь'); return $this->redirect('/user/manage/index', 301); } else { Yii::$app->session->setFlash('error', 'Возникла ошибка при регистрации'); Yii::error('Ошибка при регистрации'); return $this->refresh(); } } return $this->render('signup', ['model' => $model]); }
public function actionSignup() { if (YII_DEBUG) { error_log("[Site::Signup]"); } $this->layout = 'unsigned'; if (!\Yii::$app->user->isGuest) { return $this->goHome(); } $model = new SignupForm(); if ($model->load(Yii::$app->request->post()) && $model->signup()) { return $this->goBack(); } return $this->render('signup', ['model' => $model]); }
/** * @return string|Response */ public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { $user = $model->signup(); if ($user) { if ($model->shouldBeActivated()) { Yii::$app->getSession()->setFlash('alert', ['body' => Yii::t('yii', 'Your account has been successfully created. Check your email for further instructions.'), 'options' => ['class' => 'alert-success']]); } else { Yii::$app->getUser()->login($user); } return $this->goHome(); } } return $this->render('signup', ['model' => $model]); }
public function actionSignup() { $signup = new SignupForm(['scenario' => 'signup']); $user = new User(); $signup->email = Yii::$app->request->post('email'); $signup->password = Yii::$app->request->post('password'); $signup->display_name = Yii::$app->request->post('display_name'); if ($user = $signup->signup()) { $user->role = User::ROLE_USER; $user->save(); return json_encode(['success' => true, 'data' => $user->attributes]); } else { if ($signup->hasErrors()) { return json_encode(['success' => false, 'data' => $signup->getErrors()]); } } }
public function actionSignup() { $config = Yii::$app->config->get("signup"); if (isset($config) && !$config['allowSignup']) { throw new HttpException('403', $config['message'] ? $config['message'] : Yii::t('app', 'website signup is closed')); } $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { $user = $model->signup(); if ($user) { if (Yii::$app->getUser()->login($user)) { return $this->goHome(); } } } return $this->render('signup', ['model' => $model]); }
/** * 'signup' action: if a form is not being submitted, it displays one, * otherwise it processes the submitted data and logs the new user in. * @return mixed */ public function actionSignup() { $model = new SignupForm(); if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return \yii\bootstrap\ActiveForm::validate($model); } if ($model->load(Yii::$app->request->post())) { if ($user = $model->signup()) { Yii::info('User signed up.', __METHOD__); if (Yii::$app->getUser()->login($user)) { Yii::info('User logged in.', __METHOD__); return $this->goHome(); } } } return $this->render('signup', ['model' => $model]); }
public function actionVerify() { if (\Yii::$app->user->isGuest) { throw new NotFoundHttpException('The requested page does not exist.'); } elseif (\Yii::$app->user->identity->isActivated()) { return $this->redirect(['user/profile']); } $model = new SignupForm(['scenario' => 'activate']); if ($model->load(Yii::$app->request->get())) { if ($user = $model->activate()) { if (Yii::$app->getUser()->login($user)) { Yii::$app->session->setFlash('success', 'Аккаунт подтвержден!'); return $this->goHome(); } } } return $this->render('verify', ['model' => $model]); }
public function actionCreate() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { if (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } else { if ($model->signup()) { $this->setFlash('success', Yii::t('app', 'User has been created')); } else { $this->setFlash('error', Yii::t('app', 'User has not been created')); } return $this->redirect(['index']); } } return $this->render('form', ['model' => $model]); }
/** * render Signup.php with $model = new SignupForm(); * * @return $this->render('signup', ['model' => $model]) */ public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { $findUser = User::findByUsername($model->username); if (!$findUser) { $user = new User(); if ($user->addUser($model)) { // succeed to add User return $this->render('signup-success', ['model' => $model]); } $model->releaseErrorModel(); return $this->render('signup-success', ['model' => $model]); } $model->password = ''; /**< activate the rule */ $model->userExist('username', []); } // fail to add user, $model is changed branch statements return $this->render('signup', ['model' => $model]); }
public function actionSignup() { $model = new SignupForm(); //ajax验证 /*$model->load($_POST); if (Yii::$app->request->isAjax) { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return \yii\bootstrap\ActiveForm::validate($model); }*/ //表单提交 if ($model->load(Yii::$app->request->post())) { if ($user = $model->signup()) { if ($model->sendEmail()) { Yii::$app->session->setFlash('success', '你已经成功注册! :D '); } else { Yii::$app->session->setFlash('emailerror', '邮件发送失败 :( '); } } } return $this->render('signup', ['model' => $model]); }