Created
July 13, 2018 02:24
-
-
Save fatkulnurk/11262b96f9dc77a7f15c41b48661e525 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function actionLogin() | |
{ | |
if (!Yii::$app->user->isGuest) { | |
return $this->goHome(); | |
} | |
$session = Yii::$app->session; | |
$session->open(); | |
if (!$session['user']['login']){ | |
$model = new LoginForm(); | |
if ($model->load(Yii::$app->request->post()) && $model->login()) { | |
//return $this->goBack(); | |
$userdata = BackendUser::find()->where(['id'=>Yii::$app->user->getId()])->asArray()->all(); | |
$session['user'] = array( | |
"login" => true, | |
"id" => $userdata[0]['id'], | |
"username" => $userdata[0]['username'], | |
"fullname" => $userdata[0]['fullname'], | |
); | |
return $this->redirect(["site/index"]); | |
} else { | |
$model->password = ''; | |
return $this->render('login', [ | |
'model' => $model, | |
]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment