I need to log in to the site using the API. with the API, I send $ _POST ['username'], $ _POST ['password'] to actionLogin ().

public function actionLogin() { if (!Yii::app()->user->isGuest) $this->redirect($this->createUrl('site/_allorders')); $model = new LoginForm; if (isset($_POST['LoginForm'])) { $model->attributes = $_POST['LoginForm']; if ($model->validate()) { $this->redirect(Yii::app()->user->returnUrl); } } $this->layout = 'mini'; $this->render('_loginForm', array('model' => $model)); } 

The $ model-> validate () method normally passes, but it fails to log in. What is my mistake or what is missing?

  • So where in the code do you actually login it? o_O - Roman Grinyov
  • at this URL: http: //...........ru/client.php/site/login is the form, there and send the post - Taron
  • I mean, where do you call the login() method? - Roman Grinyov
  • Initially, I did not write the code, but when it passes through validation ($ model-> validate ()), I immediately get authorized, can I still have to write something? - Taron
  • if I say so with the API, then Yii :: app () -> user-> login ($ this -> _ identity); does not work, and if from the site, it works. Problem in session lil where not yet? - Taron

0