当前位置: 首页>>代码示例>>PHP>>正文


PHP LoginForm::login方法代码示例

本文整理汇总了PHP中common\models\LoginForm::login方法的典型用法代码示例。如果您正苦于以下问题:PHP LoginForm::login方法的具体用法?PHP LoginForm::login怎么用?PHP LoginForm::login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common\models\LoginForm的用法示例。


在下文中一共展示了LoginForm::login方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCantLoginWithoutPassword

 public function testCantLoginWithoutPassword()
 {
     test::double('common\\models\\User', ['validatePassword' => true]);
     $model = new LoginForm();
     $model->username = 'davert';
     $this->assertFalse($model->login());
     $model->password = '123456';
     $this->assertTrue($model->login());
 }
开发者ID:nsanden,项目名称:Yii2-AspectMock,代码行数:9,代码来源:LoginFormTest.php

示例2: actionLogin

 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     $serviceName = Yii::$app->getRequest()->getQueryParam('service');
     if (isset($serviceName)) {
         /** @var $eauth \nodge\eauth\ServiceBase */
         $eauth = Yii::$app->get('eauth')->getIdentity($serviceName);
         $eauth->setRedirectUrl(Yii::$app->getUser()->getReturnUrl());
         $eauth->setCancelUrl(Yii::$app->getUrlManager()->createAbsoluteUrl('site/login'));
         try {
             if ($eauth->authenticate()) {
                 $identity = User::findByEAuth($eauth);
                 Yii::$app->getUser()->login($identity);
                 // special redirect with closing popup window
                 $eauth->redirect();
             } else {
                 // close popup window and redirect to cancelUrl
                 $eauth->cancel();
             }
         } catch (\nodge\eauth\ErrorException $e) {
             // save error to show it later
             Yii::$app->getSession()->setFlash('error', 'EAuthException: ' . $e->getMessage());
             // close popup window and redirect to cancelUrl
             //              $eauth->cancel();
             $eauth->redirect($eauth->getCancelUrl());
         }
     } elseif ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack(Yii::$app->homeUrl);
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
开发者ID:KPEMATOP,项目名称:findspree_old,代码行数:35,代码来源:SiteController.php

示例3: actionLogin

 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         $request = "";
         $dosen = \backend\modules\aitk\models\AitkRDosen::findOne(['account_id' => Yii::$app->user->id]);
         $asrama = \backend\modules\aitk\models\AitkRAsrama::findOne(['account_id' => Yii::$app->user->id]);
         if (isset($dosen) || isset($asrama)) {
             if (isset($dosen)) {
                 $jumlah_request_dosen = \backend\modules\aitk\models\AitkRequest::find()->where(['status_dosen' => NULL, 'dosen_wali' => $dosen->dosen_id])->count();
             }
             $jumlah_request_asrama = \backend\modules\aitk\models\AitkRequest::find()->where(['status_dosen' => 1, 'status_asrama' => NULL])->count();
             $total_request = isset($dosen) ? $jumlah_request_dosen : (isset($asrama) ? $jumlah_request_asrama : 0);
             $url = isset($dosen) ? 'dosenwali' : 'asrama';
             if ($total_request > 0) {
                 Yii::$app->getSession()->setFlash('info', ['type' => 'info', 'delay' => 100000, 'icon' => 'glyphicon glyphicon-warning-sign', 'message' => 'Anda Memiliki <a href=' . \yii\helpers\Url::to('index.php?r=aitk/request/' . $url) . '><b>' . $total_request . ' Pending Request</b></a> ', 'title' => 'Pending Request']);
             }
         }
         return $this->redirect(['index']);
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
开发者ID:bxcodec,项目名称:Aptikad,代码行数:26,代码来源:SiteController.php

示例4: actionLogin

 public function actionLogin()
 {
     $this->layout = 'strepz_guest';
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $this->_currentRegion = str_replace('Strepz ', '', Yii::$app->name);
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->checkUsernameExists()) {
             $userRegion = strtoupper($user->region);
             if ($model->login()) {
                 if ($userRegion === $this->_currentRegion) {
                     return $this->goBack();
                 } elseif ($userRegion === 'US' && $this->_currentRegion === 'EU') {
                     if ($this->_auth_key = $model->getUser()->auth_key) {
                         $this->_username = $model->getUser()->username;
                         Yii::$app->user->logout();
                         return $this->redirect(Yii::$app->params['us_domain'] . 'index.php?r=site%2Flogin-auth&auth_key=' . $this->_auth_key . '&username=' . $this->_username);
                     }
                 } elseif ($userRegion === 'EU' && $this->_currentRegion === 'US') {
                     if ($this->_auth_key = $model->getUser()->auth_key) {
                         $this->_username = $model->getUser()->username;
                         Yii::$app->user->logout();
                         return $this->redirect(Yii::$app->params['eu_domain'] . 'index.php?r=site%2Flogin-auth&auth_key=' . $this->_auth_key . '&username=' . $this->_username);
                     }
                 }
             } else {
                 return $this->render('login', ['model' => $model]);
             }
         }
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
开发者ID:adzadzadz,项目名称:yii2-strepz,代码行数:35,代码来源:SiteController.php

示例5: actionLogin

 /**
  * Logs in a user.
  *
  * @return mixed
  */
 public function actionLogin()
 {
     $this->layout = 'main_login';
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     $signupModel = new SignupForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack();
     } elseif ($signupModel->load(Yii::$app->request->post())) {
         if ($user = $signupModel->signup()) {
             if (Yii::$app->getUser()->login($user)) {
                 $profile = new ProfileCrud();
                 $profile->user_id = $user->id;
                 $profile->fullname = $user->username;
                 $profile->email = $user->email;
                 $profile->save();
                 return $this->goHome();
             }
         }
     } else {
         return $this->render('login', ['model' => $model, 'signupModel' => $signupModel]);
     }
 }
开发者ID:resarahman,项目名称:phpindonesia.or.id-membership,代码行数:30,代码来源:SiteController.php

示例6: actionIndexadd

 public function actionIndexadd()
 {
     if (Yii::$app->user->isGuest) {
         $model = new LoginForm();
         if ($model->load(Yii::$app->request->post()) && $model->login()) {
             return $this->goBack();
         } else {
             return $this->render('/site/login', ['model' => $model]);
         }
     } else {
         $Order = new Order();
         $Order->user_id = Yii::$app->user->identity->id;
         $Order->date_time = date('Y-m-d H:i:s');
         $Order->status_id = '1';
         $Order->save();
         $Card = new CardList();
         $Products = $Card->getCardAndCardList(Yii::$app->user->identity->id);
         $Ord = new Order();
         $order_id = $Ord->GetOrderId(Yii::$app->user->identity->id);
         for ($i = 0; $i < sizeof($Products); $i++) {
             $Orderlist = new Orderlist();
             $Orderlist->order_id = $order_id[0]['MAX(`order_id`)'];
             $Orderlist->product_id = $Products[$i]['product_id'];
             $Orderlist->quantity = $Products[$i]['quantity'];
             $Orderlist->save();
         }
         $card = new Card();
         $card->DeleteCardId(Yii::$app->user->identity->id);
         $order = $Ord->GetOrdersFromID(Yii::$app->user->identity->id);
         $user = User::find()->where(['id' => Yii::$app->user->identity->id])->one();
         return $this->render('index', ['user' => $user, 'order' => $order]);
     }
 }
开发者ID:przemek207,项目名称:Nzi_Project,代码行数:33,代码来源:AccountController.php

示例7: testLoginCorrect

 public function testLoginCorrect()
 {
     $model = new LoginForm(['username' => 'bayer.hudson', 'password' => 'password_0']);
     expect('model should login user', $model->login())->true();
     expect('error message should not be set', $model->errors)->hasntKey('password');
     expect('user should be logged in', Yii::$app->user->isGuest)->false();
 }
开发者ID:yiisoft,项目名称:yii2-app-advanced,代码行数:7,代码来源:LoginFormTest.php

示例8: actionIndex

 public function actionIndex()
 {
     if (Yii::$app->user->isGuest) {
         $model = new LoginForm();
         if ($model->load(Yii::$app->request->post()) && $model->login()) {
             return $this->goBack();
         } else {
             return $this->render('/site/login', ['model' => $model]);
         }
     } else {
         if (!empty($_POST)) {
             $model = new User();
             $model = User::find()->where(['id' => Yii::$app->user->identity->id])->one();
             //$model->username = '$_POST['username']';
             //$model->email = '$_POST['email']';
             $model->country = $_POST['country'];
             $model->city = $_POST['city'];
             $model->street = $_POST['street'];
             $model->zip_code = $_POST['zip_code'];
             $model->save();
         }
         $user = User::find()->where(['id' => Yii::$app->user->identity->id])->one();
         return $this->render('index', ['user' => $user]);
     }
 }
开发者ID:keszfeayym,项目名称:Nzi_Project,代码行数:25,代码来源:AccountController.php

示例9: actionLogin

 /**
  * 登录控制
  * @return type
  */
 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         $this->redirect('/member/index.html');
     }
     $time = time();
     $time = $time - 10;
     if (!empty(\Yii::$app->request->get('id')) && !empty(\Yii::$app->request->get('stoken'))) {
         $user_id = \Yii::$app->request->get('id');
         $stoken = \Yii::$app->request->get('stoken');
         //$user = Users::model()->find(" user_id=:id AND repstaken=:repstaken AND repsativetime>=:time", array(":id"=>$user_id,":repstaken" => $stoken, ":time" => $time));
         //echo $user_id;exit;
         $user = User::find()->where(" user_id=:id", [":id" => $user_id])->one();
         //$user = User::model()->find(" user_id=:id", array(":id" => $user_id));
         if ($user) {
             $loginform = new LoginForm();
             $loginform->setAttributes(['username' => $user->username, 'password' => $user->password, 'rememberMe' => true]);
             if ($loginform->login(2)) {
                 $this->redirect('/member/index.html');
                 \Yii::$app->end();
             }
         }
     }
     $this->redirect('/public/nologin.html');
 }
开发者ID:wxzuan,项目名称:wxzuan,代码行数:29,代码来源:PublicController.php

示例10: actionLogin

 /**
  * Logs in a user.
  *
  * @return mixed
  */
 public function actionLogin()
 {
     $this->layout = 'main_login';
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     $signupModel = new SignupForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack();
     } elseif ($signupModel->load(Yii::$app->request->post())) {
         if ($user = $signupModel->signup()) {
             if (Yii::$app->getUser()->login($user)) {
                 $profile = new ProfileCrud();
                 $profile->scenario = 'signup';
                 $profile->user_id = $user->id;
                 $profile->fullname = $user->username;
                 $profile->email = ' ';
                 $profile->save();
                 if ($profile->sendEmail($user->email, 1)) {
                     Yii::$app->session->setFlash('success', 'Hi ' . $user->username . ', selamat bergabung. Mohon lakukan verifikasi email dan lengkapi profile anda. ');
                 } else {
                     Yii::$app->session->setFlash('error', 'Maaf, kami tidak dapat mengirimkan email verifikasi untuk anda.');
                 }
                 return $this->goHome();
             }
         }
     } else {
         return $this->render('login', ['model' => $model, 'signupModel' => $signupModel]);
     }
 }
开发者ID:WillymarJ,项目名称:phpindonesia.or.id-membership,代码行数:36,代码来源:SiteController.php

示例11: actionLogin

 public function actionLogin()
 {
     $model = new LoginForm();
     if ($model->load(\Yii::$app->request->post()) && $model->login()) {
         $this->goBack();
     }
     return $this->render('login', ['model' => $model]);
 }
开发者ID:pers1307,项目名称:yii,代码行数:8,代码来源:MainController.php

示例12: run

 public function run()
 {
     $model = new LoginForm();
     if ($model->load(\Yii::$app->request->post()) && $model->login()) {
         \Yii::$app->controller->redirect(\Yii::$app->controller->goBack());
     }
     return $this->render('login', ['model' => $model]);
 }
开发者ID:vecherskyy,项目名称:dom,代码行数:8,代码来源:Login.php

示例13: testLoginCorrect

 public function testLoginCorrect()
 {
     $model = new LoginForm(['username' => 'admin', 'password' => 'admin']);
     $this->specify('用户应该正常登录', function () use($model) {
         expect('login方法应该返回true', $model->login())->true();
         expect('密码错误信息应该不被设置', $model->errors)->hasntKey('password');
         expect('用户应该登录成功', Yii::$app->user->isGuest)->false();
     });
 }
开发者ID:phpdn,项目名称:qc-base,代码行数:9,代码来源:LoginFormTest.php

示例14: actionLogin

 /**
  * Logs in a user.
  *
  * @return mixed
  */
 public function actionLogin()
 {
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack();
     } else {
         return $this->goHome();
     }
 }
开发者ID:kentuck13,项目名称:blog-yii2,代码行数:14,代码来源:SiteController.php

示例15: actionLoginSubmit

 public function actionLoginSubmit()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $model = new LoginForm();
     if ($model->load(["LoginForm" => Yii::$app->request->post()]) && $model->login()) {
         return ["code" => 200, "msg" => "登录成功!"];
     }
     return ["code" => 300, "msg" => "登录失败", "errors" => $model->errors];
 }
开发者ID:xiaomige,项目名称:giishop,代码行数:9,代码来源:SiteController.php


注:本文中的common\models\LoginForm::login方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。