I
I
Ivan2014-04-13 12:09:10
Yii
Ivan, 2014-04-13 12:09:10

Authorization in Yii stopped working after changing VPS?

In continuation to Why does the server have some left hostname?
Authorization stopped working. The problem is that after successful validation, a redirect to the main page occurs, but authorization does not occur. And in the firebug console, the following oddities:
0540a3da17484ccd854ff55bc05ee8d9.png94af45939e5b499aa10addd6def0c968.png620f3661e6cf4194af0b01126e5fb10d.png
In response to the post-request, some left phrase comes "Reload the page to get the source for: http://site.ru/login"
AuthController controller code:

public function actionLogin() {
  if (!Yii::app()->user->isGuest)
    $this->redirect(Yii::app()->homeUrl);
  
  $user = new User(User::SCENARIO_LOGIN);
  $request = Yii::app()->request;
  /*$ajaxRequest = $request->getPost('ajax', false);
  if ($ajaxRequest && $ajaxRequest === 'login-form') {
    echo CActiveForm::validate($user);
    Yii::app()->end();
  }*/
  $formData = $request->getPost(get_class($user), false);
  
  if ($formData) {
    $user->attributes = $formData;
    if ($user->validate()) {
      Yii::app()->user->setFlash('success', 'Welcome back, ' . Yii::app()->user->email . '!');
      //$this->redirect(Yii::app()->user->returnUrl);
      $this->redirect(Yii::app()->homeUrl);
    }
  }
  
  $this->pageTitle[] = Yii::t('site', 'Login');
  $this->render('login', compact(array('user')));
}

It all started after moving to another VPS. At first I thought that it was because of the server's left hostname (there was such a problem), but after fixing it, the situation did not change.
Where to look?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander N++, 2014-04-13
@0neS

That's right, the code section is being executed

if ($user->validate()) {
      Yii::app()->user->setFlash('success', 'Welcome back, ' . Yii::app()->user->email . '!');
      //$this->redirect(Yii::app()->user->returnUrl);
      $this->redirect(Yii::app()->homeUrl);
    }

Look in the session what not to eat?
If you use a redirect in your code, then use a breakpoint;
return; or exit(1) aka Yii::app()->end();

M
mtdn, 2015-04-03
@mtdn

Check php write permissions in the sessions folder. On centos by default /var/lib/php/sessions

A
Alexander Urich, 2015-04-03
@Urichalex

Where does authorization take place? There is no identity creation or authentication in action. The fact that the form has been validated does not mean that authorization has occurred. Or is it in your model in the login validation?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question