Пример #1
0
 public function loginAction()
 {
     if (F::$app->getRequest()->getIsPost()) {
         $loginForm = new LoginForm();
         $loginForm->username = $_POST['username'];
         $loginForm->password = $_POST['password'];
         $userIdentity = $loginForm->login();
         if ($userIdentity instanceof User) {
             if (F::$app->getUser()->login($userIdentity)) {
                 $returnUrl = F::$app->getUser()->getReturnUrl();
                 F::$app->getResponse()->redirect($returnUrl);
             }
         }
     }
     return $this->render('login');
 }
Пример #2
0
 public function actionLogin($params = '')
 {
     $model = new LoginForm();
     $params['model'] = $model;
     if (!App::getComponent('user')->isGuest()) {
         $this->redirect('contacts');
     }
     if (isset($_POST['LoginForm'])) {
         $model->username = $_POST['LoginForm']['username'];
         $model->password = $_POST['LoginForm']['password'];
         if ($model->login()) {
             $this->redirect('contacts');
         }
     }
     $this->layout = 'login';
     return $this->render('login', $params);
 }