Hi all! It took that if after the registration occurred automatic Authorization… For this I created actionRegistration()
public function actionRegistration()
{
$model = new User;
if(isset($_POST['User']))
{
$model->attributes=$_POST['User'];
if ($model->save()) {
$identity = new UserIdentity($model->name, $model->password);
$identity->authenticate();
Yii::app()->user->login(new UserIdentity($identity));
$this->redirect('registrationCompany');
}
}
if (Yii::app()->user->isGuest) {
$this->render('registration',array('model'=>$model,));
}else{
$this->redirect(Yii::app()->user->returnUrl);
}
}
After post form, i see errors…
Missing argument 2 for CUserIdentity::__construct(), called in
public\protected\controllers\SiteController.php on line 173 and defined
and
\yii\web\auth\CUserIdentity.php(43)
43 public function __construct($username,$password)
44 {
45 $this->username=$username;
46 $this->password=$password;
47 }
my UserIdentity class
class UserIdentity extends CUserIdentity
{
private $_id;
public function authenticate()
{
$username = strtolower($this->name);
$user = User::model()->find('LOWER(name)=?', array($username));
if ($user===null)
$this->errorCode=self::ERROR_USERNAME_INVALID;
else if(!$user->validatePassword($this->password))
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else{
$this->_id=$user->id;
$this->username=$user->name;
$this->errorCode=self::ERROR_NONE;
}
return $this->errorCode==self::ERROR_NONE;
}
public function getId(){
return $this->_id;
}
}
Help to optimize it plase… I am new to yii…