Пример #1
0
 public function actionSignup()
 {
     $model = new SignupForm();
     if ($model->load(Yii::$app->request->post())) {
         $user = $model->signup();
         // var_dump($user);
         if ($user = $model->signup()) {
             if (Yii::$app->getUser()->login($user)) {
                 return $this->goHome();
             }
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
Пример #2
0
 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]);
 }
Пример #3
0
 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 actionSignup()
 {
     $model = new SignupForm();
     if ($model->load(Yii::$app->request->post()) && $model->signup()) {
         return $this->goHome();
     }
     return $this->render('signup', ['model' => $model]);
 }
Пример #5
0
 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]);
     }
 }
Пример #6
0
 /**
  * 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];
     }
 }
Пример #7
0
 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]);
 }
Пример #8
0
 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]);
 }
Пример #9
0
 /**
  * @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]);
 }
Пример #10
0
 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]);
 }
Пример #11
0
 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]);
 }
Пример #12
0
 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;
 }
Пример #13
0
 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.');
 }
Пример #14
0
 /**
  * РЕГИСТРАЦИЯ
  * @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]);
 }
Пример #15
0
 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]);
 }
Пример #16
0
 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]);
 }
 /**
  * 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]);
 }
Пример #18
0
 /**
  * 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();
     }
 }
Пример #19
0
 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]);
 }
Пример #20
0
 /**
  * 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]);
 }
Пример #21
0
 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]);
 }
Пример #22
0
 /**
  * @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]);
 }
Пример #23
0
 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()]);
         }
     }
 }
Пример #24
0
 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]);
 }
Пример #25
0
 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]);
 }
Пример #26
0
 public function actionSignup()
 {
     $model = new SignupForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->signup()) {
             //Registou com sucesso
             Yii::$app->getSession()->setFlash('success', '<h2>Sucesso!!!</h2>' . '<b>O seu pedido foi registado com sucesso.</b>' . '<br>' . 'Para efeitos de confirmação foi enviado um email para si, p.f. verifique a sua caixa de correio.' . '<br>' . '<br>' . '<i>Só puderá usar o site após boa confirmação do registo.</i>');
             return $this->redirect("/site/message");
         } else {
             Yii::$app->getSession()->setFlash('danger', '<h2>Lamentamos !!!</h2>' . 'Não foi possível efetuar o seu registo neste momento.' . 'P.f. confirme os dados introduzidos e volte a tentar.');
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
Пример #27
0
 /**
  * This function will be triggered when user is successfuly authenticated using some oAuth client.
  *
  * @param yii\authclient\ClientInterface $client
  * @return boolean|yii\web\Response
  */
 public function oAuthSuccess($client)
 {
     // get user data from client
     $userAttributes = $client->getUserAttributes();
     //cuida de logar
     $user = User::find()->where(['=', 'email', $userAttributes['email']])->one();
     if ($user != null) {
         Yii::$app->user->login($user);
         copy('http://graph.facebook.com/' . $user->username . '/picture?type=large', 'images/' . $user->username . '.jpeg');
         return $this->goHome();
     } else {
         $modelCadastro = new SignupForm();
         $modelCadastro->email = $userAttributes['email'];
         $modelCadastro->username = $userAttributes['id'];
         $modelCadastro->password = $userAttributes['id'];
         $nome = explode(" ", $userAttributes['name']);
         if ($user = $modelCadastro->signup()) {
             $modelPerfil = new Perfil();
             $modelPerfil->id = $user->id;
             $modelPerfil->data = date('Y-m-d');
             $modelPerfil->nome = $nome[0];
             $modelPerfil->sobrenome = $nome[1];
             copy('http://graph.facebook.com/' . $modelCadastro->username . '/picture?type=large', 'images/' . $modelCadastro->username . '.jpeg');
             $modelPerfil->foto = $modelCadastro->username . '.jpeg';
             $modelPerfil->save();
             if (Yii::$app->getUser()->login($user)) {
                 return $this->goHome();
             }
         }
     }
     //Cuida do cadastro do usuario na base
     // do some thing with user data. for example with $userAttributes['email']
 }
Пример #28
0
 public function actionSignup()
 {
     $model = new SignupForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->signup()) {
             if (Yii::$app->getUser()->login($user)) {
                 $auth = Yii::$app->authManager;
                 $authorRole = $auth->getRole('user');
                 $auth->assign($authorRole, $user->getId());
                 return $this->goHome();
             }
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
Пример #29
0
 public function testNotCorrectSignup()
 {
     $model = new SignupForm(['login' => 'troy.becker', 'password' => 'some_password', 'repeatPassword' => 'some_password', 'email' => '*****@*****.**']);
     expect('username and email are in use, user should not be created', $model->signup());
 }
Пример #30
0
 public function actionSignup()
 {
     if (Yii::$app->user->identity->username == "zama") {
         $model = new SignupForm();
         $empleado = new Empleado();
         if ($model->load(Yii::$app->request->post()) && $empleado->load(Yii::$app->request->post())) {
             $empleado->estatus_did = 1;
             if ($empleado->validate() && $model->validate()) {
                 $empleado->save();
                 $model->empleado_did = $empleado->id;
                 if ($user = $model->signup()) {
                     if (Yii::$app->getUser()->login($user)) {
                         return $this->goHome();
                     }
                 }
             }
         }
         return $this->render('signup', ['model' => $model, 'empleado' => $empleado]);
     } else {
         return $this->goHome();
     }
 }