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


PHP Users::login方法代码示例

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


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

示例1: actionLogin

 public function actionLogin()
 {
     if (empty($_POST) == false) {
         $user = \App\Models\Users::login($_POST);
         if (empty($user) == false) {
             $sess = md5(microtime());
             $user->setSess($sess);
             $_SESSION['sess'] = $sess;
             header('Location: http://test/index.php');
         } else {
             $this->view->msg = 'Неверный логин или пароль';
             $this->view->display('login');
         }
     } else {
         $this->view->display('login');
     }
 }
开发者ID:ShatrovStanislav,项目名称:test,代码行数:17,代码来源:Users.php

示例2: actionIndex

 public function actionIndex()
 {
     if (Yii::$app->User->isGuest) {
         $role = Users::findOne(Yii::$app->request->get('Users'))->role;
         $newmodel = new Users();
         $newmodel->scenario = 'login';
         //if model can load get request and User->login is true
         if ($newmodel->load(Yii::$app->request->get()) && $newmodel->login()) {
             if ($role == 1) {
                 if (Yii::$app->request->get('type') == 'auto') {
                     $this->redirect(['auto/index']);
                 } elseif (Yii::$app->request->get('type') == 'guest') {
                     $this->redirect(['pass/index']);
                 } else {
                     return $this->render('withoutlogin');
                 }
             } elseif ($role == 2) {
                 if (Yii::$app->request->get('type') == 'auto') {
                     $this->redirect(['auto/admin']);
                 } elseif (Yii::$app->request->get('type') == 'guest') {
                     $this->redirect(['pass/admin']);
                 } else {
                     return $this->render('withoutlogin');
                 }
             } elseif ($role == 3) {
                 if (Yii::$app->request->get('type') == 'auto') {
                     $this->redirect(['auto/disp']);
                 } elseif (Yii::$app->request->get('type') == 'guest') {
                     $this->redirect(['pass/disp']);
                 } else {
                     return $this->render('withoutlogin');
                 }
             } elseif ($role == 4) {
                 $this->redirect(['admin/index']);
             } else {
                 return $this->goHome();
             }
         } else {
             $model = Users::find()->all();
             return $this->render('index', ['model' => $model, 'newmodel' => $newmodel]);
         }
     } else {
         $role = Users::find()->where(['username' => Yii::$app->user->identity->username])->one()->role;
         if ($role == 1) {
             if (Yii::$app->request->get('type') == 'auto') {
                 $this->redirect(['auto/index']);
             } elseif (Yii::$app->request->get('type') == 'guest') {
                 $this->redirect(['pass/index']);
             } else {
                 return $this->render('withoutlogin');
             }
         } elseif ($role == 2) {
             if (Yii::$app->request->get('type') == 'auto') {
                 $this->redirect(['auto/admin']);
             } elseif (Yii::$app->request->get('type') == 'guest') {
                 $this->redirect(['pass/admin']);
             } else {
                 return $this->render('withoutlogin');
             }
         } elseif ($role == 3) {
             if (Yii::$app->request->get('type') == 'auto') {
                 $this->redirect(['auto/disp']);
             } elseif (Yii::$app->request->get('type') == 'guest') {
                 $this->redirect(['pass/disp']);
             } else {
                 return $this->render('withoutlogin');
             }
         } elseif ($role == 4) {
             $this->redirect(['admin/index']);
         } else {
             return $this->goHome();
         }
     }
 }
开发者ID:dmitriytyoskin,项目名称:Simple-Pass-System-on-Yii2,代码行数:74,代码来源:SiteController.php


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