本文整理汇总了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');
}
}
示例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();
}
}
}