Пример #1
0
 public function actionSignupSubmit()
 {
     if (isset(Yii::$app->request->post('SignupForm')['checkbox'])) {
         $IsLogin = true;
     } else {
         $IsLogin = false;
     }
     $model = new SignupForm();
     if (Yii::$app->request->isAjax) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         $model->load(Yii::$app->request->post());
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($user = $model->signup() && $IsLogin) {
             // если есть чекбокс залогинить
             $model->login($user);
             return $this->redirect('/shop/index');
         } else {
             // если не просили залогинить
             //vd(yii::$app->request->isAjax);
             Yii::$app->response->format = Response::FORMAT_JSON;
             Yii::$app->getSession()->setFlash('success', 'Вы успешно зарегистрировались');
             return $this->redirect('/shop/index');
         }
     }
     return $this->redirect('/shop/signup');
 }
Пример #2
0
 public function actionSignup()
 {
     if (!Yii::$app->user->isGuest) {
         return $this->goBack();
     }
     //new a signup model here
     $signUpModel = new SignupForm();
     if (Yii::$app->request->post()) {
         //load all the data from post into model
         if ($signUpModel->load(Yii::$app->request->post())) {
             //if successed
             if ($user = $signUpModel->signup()) {
                 if (Yii::$app->getUser()->login($user)) {
                     //sent a eamil for validation
                     $mail = Yii::$app->mailer->compose();
                     $mail->setTo($user->username);
                     $mail->setSubject("账号激活");
                     $validate_url = 'http://localhost/project_colfans/yii2forcolfans/frontend/web/site/validateaccount?user='******'&validation=' . $user->validation;
                     $mail->setHtmlBody('点击下方链接激活账号,如果您并没有在Colfans注册账号,请忽略此邮件<a style="color:#4383E5;font-size:16px;" href="' . $validate_url . '" target="_blank">点这里</a>');
                     $mail->send();
                     $this->redirect(['index', 'message' => 'newaccount', 'email' => $user->username]);
                 }
             }
         }
     }
     return $this->render('signup', ['signUpModel' => $signUpModel]);
 }
Пример #3
0
 public function actionCreate()
 {
     $model = new SignupForm();
     $parseData['model'] = $model;
     // get user types
     $types = $model->_types;
     $role = new Role();
     if ($role->isAdmin) {
         foreach ($types as $key => $value) {
             if ($value['value'] == User::TYPE_ADMIN) {
                 unset($types[$key]);
             }
         }
     }
     $parseData['types'] = $model->_prepareDataSelect($types, 'value', 'label');
     $post = Yii::$app->request->post();
     if ($post) {
         $model->load(Yii::$app->request->post());
         if ($model->validate()) {
             $model->signup();
             return $this->redirect(['index']);
         } else {
             $parseData['errors'] = $model->getErrors();
         }
     }
     return $this->render('create', $parseData);
 }
 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new SignupForm();
     if ($model->load(Yii::$app->request->post()) && $model->signup()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Пример #5
0
 /**
  * Creates a new User for current Tenant.
  * If creation is successful, the browser will be redirected to Tenant 'view' page.
  * @return mixed
  */
 public function actionCreateuser()
 {
     $model = new SignupForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->signup()) {
             return $this->actionView($model->tenant_id);
         }
     }
     return $this->render('createuser', ['model' => $model]);
 }
Пример #6
0
 public function actionSignupSubmit()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $model = new SignupForm();
     if ($model->load(["SignupForm" => Yii::$app->request->post()]) && ($user = $model->signup())) {
         if (Yii::$app->getUser()->login($user)) {
             return ["code" => 200, "msg" => "注册成功!"];
         }
     }
     return ["code" => 300, "msg" => "注册失败", "errors" => $model->errors];
 }
Пример #7
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)) {
                 return \Yii::$app->getResponse()->redirect(Yii::$app->params['backend_url']);
             }
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
Пример #8
0
 public function saveMember($event)
 {
     /** @var \modules\member\models\VerificationCode $verificationCode */
     /** @var Event $event */
     $verificationCode = $event->sender;
     $phone = $verificationCode->field;
     if (wanhunet::$app->user->isGuest) {
         $model = new SignupForm();
         $model->load(['username' => $phone, 'phone' => $phone, 'password' => wanhunet::$app->request->post('password')]);
         $model->signup();
     }
 }
Пример #9
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();
             }
         }
     }
     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()) {
             Yii::$app->db->createCommand()->insert('{{%user_profile}}', ['user_id' => $user->id])->execute();
             if (Yii::$app->getUser()->login($user)) {
                 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)) {
                 Yii::$app->getSession()->setFlash('success', '申请注册成功,请耐心等待账号激活');
                 return $this->goHome();
             }
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
Пример #12
0
 public function actionRegister()
 {
     $model = new SignupForm();
     //if($model->load(\Yii::$app->request->post()) && $model->validate())
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->signup()) {
             if (Yii::$app->getUser()->login($user)) {
                 return $this->goHome();
             }
         }
     }
     return $this->render('register', ['model' => $model]);
 }
Пример #13
0
 public function actionSignup()
 {
     $model = new SignupForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->signup()) {
             if (Yii::$app->getUser()->login($user)) {
                 \Yii::$app->getSession()->setFlash('success', 'Ви успішно зареєструвались. Дякуємо, що скористались нашим сервісом.');
                 return $this->goHome();
             }
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
Пример #14
0
 /**
  * @return string|\yii\web\Response
  * @throws \yii\web\NotFoundHttpException
  */
 function actionSignup()
 {
     $sign_model = new SignupForm();
     if ($sign_model->load(Yii::$app->request->post())) {
         if ($user = $sign_model->signup()) {
             if (Yii::$app->getUser()->login($user)) {
                 return $this->goHome();
             }
         }
     }
     $js = '$("#sign-modal").modal("show")';
     $this->getView()->registerJs($js);
     return $this->render('signup', ['sign_model' => $sign_model]);
 }
Пример #15
0
 public function actionSignup()
 {
     $this->title = '用户注册' . ' - ' . Yii::$app->name;
     $this->description = '';
     $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]);
 }
Пример #16
0
 public function actionRegister()
 {
     $model = new SignupForm();
     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', 'Register Success');
     }
     return $this->render("register", ['model' => $model]);
 }
Пример #17
0
 public function actionRegister()
 {
     $this->layout = 'inner';
     $model = new SignupForm();
     //        $model->scenario = 'short_register';
     if (Yii::$app->request->isAjax && $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', 'Register success');
     }
     return $this->render('register', ['model' => $model]);
 }
Пример #18
0
 public function actionSignup()
 {
     $model = new SignupForm();
     if ($model->load(Yii::$app->request->post())) {
         $model->imageFile = UploadedFile::getInstance($model, 'imageFile');
         if ($user = $model->signup()) {
             //$model->imageFile = UploadedFile::getInstance($model, 'imageFile');
             if (Yii::$app->getUser()->login($user)) {
                 return $this->goHome();
             }
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
Пример #19
0
 /**
  * Регистрация пользователя
  * @return string|Response
  */
 public function actionSignup()
 {
     $model = new SignupForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->signup()) {
             Yii::$app->getSession()->setFlash('success', 'Вам отправлено письмо со ссылкой для подтверждения email.');
             return $this->goHome();
         } else {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return $model->getFormattedError();
         }
     }
     return $this->renderAjax('signup', ['model' => $model]);
 }
Пример #20
0
 public function actionSignup()
 {
     $this->title = '用户注册' . ' - ' . Yii::$app->name;
     $this->description = '';
     $this->canonical = Yii::$app->params['domain'] . 'signup';
     $model = new SignupForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->signup()) {
             Yii::$app->cache->delete('UserCount');
             if (Yii::$app->getUser()->login($user)) {
                 return $this->goHome();
             }
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
Пример #21
0
 public function actionSignUp()
 {
     $model = new SignupForm();
     if ($model->load(Yii::$app->getRequest()->getBodyParams(), '') && $model->validate()) {
         $user = $model->signup();
         if ($user) {
             Yii::$app->user->login($user, 3600 * 24 * 30);
             $response = ['access_token' => Yii::$app->user->identity->getAuthKey(), 'flash' => ['class' => 'success', 'message' => 'Thank you. You are successfully sign up.']];
         } else {
             $response = ['flash' => ['class' => 'error', 'message' => 'Something wrong.']];
         }
         return $response;
     } else {
         $model->validate();
         return $model;
     }
 }
Пример #22
0
 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;
             \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', 'Register Success');
         //print_r($model->getAttributes());
         //die;
     }
     return $this->render('register', ['model' => $model]);
 }
Пример #23
0
 /**
  * Signs user up.
  *
  * @return mixed
  */
 public function actionSignup()
 {
     $model = new SignupForm();
     if ($model->load(Yii::$app->request->post())) {
         /*
          * Upload avatar file, save
          */
         $model->avatar_file = UploadedFile::getInstance($model, 'avatar_file');
         $model->avatar_file->saveAs('avatars/' . $model->username . '.' . $model->avatar_file->extension);
         $model->avatar = 'avatars/' . $model->username . '.' . $model->avatar_file->extension;
         if ($user = $model->signup()) {
             if (Yii::$app->getUser()->login($user)) {
                 return $this->goHome();
             }
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
Пример #24
0
 public function actionRegister()
 {
     $registerForm = new SignupForm();
     if ($registerForm->load(\Yii::$app->request->post()) && $registerForm->validate()) {
         /*
                     \Yii::$app->common->sendMail(Html::encode($registerForm->email), Html::encode($registerForm->username), Html::encode($registerForm->password_hash));
                     $userModel = new UserDbModel();
                     $userModel->username = Html::encode($registerForm->username);
                     $userModel->email = Html::encode($registerForm->email);
                     $userModel->password_hash = \Yii::$app->security->generatePasswordHash(Html::encode($registerForm->password_hash));
                     $userModel->generateAuthKey();
                     $userModel->save();
                     //*/
         $registerForm->signup();
         return $this->render('registerView', ['formModel' => $registerForm, 'success' => true]);
     } else {
         return $this->render('registerView', ['formModel' => $registerForm]);
     }
 }
Пример #25
0
 public function actionSignup()
 {
     $model = new SignupForm();
     /*
      * Author :: Ashutosh
      * this snippet here checks for ajax request
      */
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     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]);
 }
Пример #26
0
 public function actionSignup()
 {
     //var_dump(mt_rand(100, 999)); exit;
     $model = new SignupForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->signup()) {
             //send mail
             Yii::$app->mail->compose()->setTo($user->email)->setFrom('*****@*****.**')->setSubject('Verify your Email -Medieasy')->setHtmlBody('Welcome <b>' . $user->username . '</b></br>
                         <p>Please click the below link to verify your email.</p></br>
                         <a href="http://localhost/medieasy/site/verifyemail?key=' . $user->auth_key . '">
                         ' . Yii::$app->urlManager->createUrl('site/verifyemail?key=') . $user->auth_key . '
                         </a> </br><p> Thank You,</p></br><p><b>Medieasy</b></p>')->send();
             Yii::$app->session->setFlash('success', 'You are successfully created account on Medieasy. Mail has been Sent. You must verify Your email before login.');
             return $this->redirect('login');
             // if (Yii::$app->getUser()->login($user)) {
             //     return $this->goHome();
             // }
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
Пример #27
0
 public function actionCreate($parent_id = null)
 {
     $parentId = (int) Yii::$app->request->queryParams['parent_id'];
     $parent = User::findOne($parentId);
     if ($parent instanceof User !== true) {
         throw new InvalidParamException('Invalid supplied parent-id');
     }
     $model = new SignupForm();
     $model->parentId = $parentId;
     if (!Yii::$app->request->isPost) {
         return $this->render('create', ['model' => $model, 'parent' => $parent]);
     }
     if ($model->load(Yii::$app->request->post())) {
         $uname = 'user' . mt_rand(1000, 9999);
         $model->username = $uname;
         $model->password = $uname;
         $model->email = $uname . '@yopmail.com';
         if ($user = $model->signup()) {
             return $this->redirect(array('index'));
         }
     }
     return $this->render('create', ['model' => $model, 'parent' => $parent]);
 }
Пример #28
0
 public function actionInvite()
 {
     $data = Yii::$app->getRequest()->getQueryParam("auth_key");
     if (!empty($data) && $this->getInviteKey($data)) {
         $model = new SignupForm();
         if ($model->load(Yii::$app->request->post())) {
             if (Yii::$app->request->isAjax) {
                 Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
                 return \yii\bootstrap\ActiveForm::validate($model);
             }
             if ($user = $model->signup()) {
                 $invite = Invitation::find()->where(['send_key' => $data, 'email' => $model->email])->one();
                 $invite->status = Invitation::STATUS_SIGNUP;
                 $invite->save();
                 if (Yii::$app->getUser()->login($user)) {
                     return $this->goHome();
                 }
             }
         }
         return $this->render('signup', ['model' => $model, 'auth_key' => $data]);
     }
     Yii::$app->session->setFlash("error", "You do not have permision");
     return $this->redirect([DIRECTORY_SEPARATOR]);
 }
Пример #29
0
 /**
  * Signs user up.
  *
  * @return mixed
  */
 public function actionSignup()
 {
     $model = new SignupForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->signup()) {
             if (Yii::$app->getUser()->login($user)) {
                 $user_id = Yii::$app->user->identity->id;
                 $cookies = Yii::$app->response->cookies;
                 if (isset($_COOKIE['cart_' . $user_id])) {
                     return $this->redirect('/cart');
                 }
                 if (isset($_COOKIE['cart_0'])) {
                     return $this->redirect('/cart');
                 }
                 return $this->goHome();
             }
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
Пример #30
0
 public function actionSignup()
 {
     /*Stripe::setApiKey('sk_test_ECfaqBtkN6P4lKr1YUEHumHf');
       try {
           $customer=Customer::retrieve('cus_7BbJnxMxcyyor');
       
       p($customer);
         // Use Stripe's bindings...
       } catch(\Stripe\Error\Card $e) {
         // Since it's a decline, \Stripe\Error\Card will be caught
         $body = $e->getJsonBody();
         $err  = $body['error'];
         $err['status']=$e->getHttpStatus();
         
       } catch (\Stripe\Error\RateLimit $e) {
         // Too many requests made to the API too quickly
       } catch (\Stripe\Error\InvalidRequest $e) {
         // Invalid parameters were supplied to Stripe's API
       } catch (\Stripe\Error\Authentication $e) {
         // Authentication with Stripe's API failed
         // (maybe you changed API keys recently)
       } catch (\Stripe\Error\ApiConnection $e) {
         // Network communication with Stripe failed
       } catch (\Stripe\Error\Base $e) {
         // Display a very generic error to the user, and maybe send
         // yourself an email
       } catch (Exception $e) {
         // Something else happened, completely unrelated to Stripe
       }*/
     $model = new SignupForm();
     //
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     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]);
 }