コード例 #1
0
ファイル: LoginController.php プロジェクト: efueger/luya
 public function actionIndex()
 {
     $url = YiiUrl::to(Url::to('admin'), true);
     // redirect logged in users
     if (!Yii::$app->adminuser->isGuest) {
         return $this->redirect($url);
     }
     // get the login form model
     $model = new \admin\models\LoginForm();
     // see if values are sent via post
     if (isset($_POST['login'])) {
         $model->attributes = $_POST['login'];
         if (($userObject = $model->login()) !== false) {
             if (Yii::$app->adminuser->login($userObject)) {
                 return $this->redirect($url);
             }
         }
     }
     $this->view->registerJs("\$('#email').focus();");
     return $this->render('index', ['model' => $model]);
 }
コード例 #2
0
 public function actionIndex()
 {
     $url = Url::base(true) . '/admin';
     // redirect logged in users
     if (!Yii::$app->adminuser->isGuest) {
         return $this->redirect($url);
     }
     // get the login form model
     $model = new \admin\models\LoginForm();
     // see if values are sent via post
     if (Yii::$app->request->post('login')) {
         $model->attributes = Yii::$app->request->post('login');
         if (($userObject = $model->login()) !== false) {
             if (Yii::$app->adminuser->login($userObject)) {
                 return $this->redirect($url);
             }
         }
     }
     $this->view->registerJs("\$(function(){ \$('#email').focus(); observeLogin('#loginForm', '" . Url::toAjax('admin/login/async') . "', '" . Url::toAjax('admin/login/async-token') . "'); });", \luya\web\View::POS_END);
     return $this->render('index', ['model' => $model]);
 }