本文整理汇总了PHP中common\models\LoginForm::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP LoginForm::getUser方法的具体用法?PHP LoginForm::getUser怎么用?PHP LoginForm::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\LoginForm
的用法示例。
在下文中一共展示了LoginForm::getUser方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRole
public static function getRole()
{
$mode = new LoginForm();
$mode->username = \Yii::$app->user->identity->username;
$role;
$user = new User();
if ($user = $mode->getUser()) {
$role = $user->role;
} else {
$role = null;
}
return $role;
}
示例2: actionLogin
/**
* Logs in a user.
*
* @return mixed
*/
public function actionLogin()
{
if (!\Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
$user = $model->getUser();
//set name in session
Yii::$app->session->set('user.name', $user['firstname']);
$type = $user['type'];
if ($type == 'Tutor' || $type == 'tutor') {
return $this->redirect('index.php?r=file/index');
} else {
return $this->render('studentHome');
}
} else {
return $this->render('login', ['model' => $model]);
}
}
示例3: actionLogin
public function actionLogin()
{
if (!\Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$_user = new User();
if ($_user = $model->getUser()) {
if ($_user->role == 'Admin') {
$model->login();
return $this->goHome();
} else {
return $this->render('login', ['model' => $model]);
}
} else {
return $this->render('login', ['model' => $model]);
}
} else {
return $this->render('login', ['model' => $model]);
}
}
示例4: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
if (($role = priviledge::getRole()) == 'Admin') {
$model = new Task();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$model->url = strtolower($model->url);
$model->status = 'Pending';
//$model->user_id = \Yii::$app->user->identity;
$mode = new LoginForm();
$mode->username = \Yii::$app->user->identity->username;
$user = new User();
if ($user = $mode->getUser()) {
$model->user_id = $user->id;
}
$listsocmed = $_POST['Task']['socmed'];
$model->facebook = 'No';
$model->twitter = 'No';
foreach ($listsocmed as $value) {
if ($value == 'Facebook') {
$model->facebook = 'Yes';
}
if ($value == 'Twitter') {
$model->twitter = 'Yes';
}
}
if ($model->save()) {
return $this->redirect(['view', 'id' => $model->task_id]);
} else {
return $this->render('create', ['model' => $model]);
}
} else {
return $this->render('create', ['model' => $model]);
}
} else {
throw new ForbiddenHttpException();
}
}
示例5: LoginForm
<?php
/* @var $this yii\web\View */
use yii\helpers\Html;
use yii\grid\GridView;
use yii\web\BadRequestHttpException;
use common\models\LoginForm;
use common\models\User;
$mode = new LoginForm();
$mode->username = \Yii::$app->user->identity->username;
$user = new User();
if (!($user = $mode->getUser())) {
throw new BadRequestHttpException();
}
$this->title = 'Homepage ' . $user->role;
?>
<div class="site-index">
<div class="jumbotron">
<h2>Selamat Datang di Halaman <?php
echo $user->role;
?>
!</h2>
</div>
</div>
示例6: actionLoginAuth
public function actionLoginAuth($auth_key = null, $username = null)
{
if ($auth_key !== null && $username !== null) {
$model = new LoginForm();
$model->username = $username;
if ($user = $model->getUser()) {
if ($user->auth_key === $auth_key) {
if (Yii::$app->user->login($user) !== null) {
return $this->goHome();
}
}
}
}
return $this->redirect(['/site/login']);
}