I m getting login problem with yii2/php7 and mongodb, i m using yii2-mongodb extension version 2.1.1 but getting problem with user login
Yii::$app->user->identity->username returns nothing
following is my main-local file code
<?php
return [
'components' => [
// 'db' => [
// 'class' => 'yii\db\Connection',
// 'dsn' => 'mysql:host=localhost;dbname=dbadvanced',
// 'username' => 'root',
// 'password' => 'mysql',
// 'charset' => 'utf8',
// ],
'mongodb' => [
'class' => '\yii\mongodb\Connection',
'dsn' => 'mongodb://localhost:27017/dbmail',
// 'enableLogging' => true, // enable logging
// 'enableProfiling' => true, // enable profiling
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,
],
],
];
and the follwoing function returns
protected function getUser()
{
if ($this->_user === null) {
$this->_user = User::findByUsername($this->username);
echo "<pre>";
VarDumper::dump($this->_user);
exit;
}
//echo $this->_user;
//exit;
return $this->_user;
}
common\models\User#1
(
[yii\db\BaseActiveRecord:_attributes] => [
'_id' => MongoDB\BSON\ObjectID#2
(
)
'username' => 'Amjad'
'email' => 'amjad@gmail.com'
'password_hash' => '$2y$13$moBu2idk1AVldKGicblX0.i7cfmKyEd0raKIOD2a77YKYMon5Rgfi'
'auth_key' => 'XWIODqbJO_ydIoI9DW1Tya4mjvJWY56M'
'status' => 10
'role' => 'user'
'created_at' => 1476207092
'updated_at' => 1476207092
]
[yii\db\BaseActiveRecord:_oldAttributes] => [
'_id' => MongoDB\BSON\ObjectID#2(...)
'username' => 'Amjad'
'email' => 'amjad@gmail.com'
'password_hash' => '$2y$13$moBu2idk1AVldKGicblX0.i7cfmKyEd0raKIOD2a77YKYMon5Rgfi'
'auth_key' => 'XWIODqbJO_ydIoI9DW1Tya4mjvJWY56M'
'status' => 10
'role' => 'user'
'created_at' => 1476207092
'updated_at' => 1476207092
]
[yii\db\BaseActiveRecord:_related] => []
[yii\base\Model:_errors] => null
[yii\base\Model:_validators] => null
[yii\base\Model:_scenario] => 'default'
[yii\base\Component:_events] => [
'beforeInsert' => [
0 => [
0 => [
0 => yii\behaviors\TimestampBehavior#3
(
[createdAtAttribute] => 'created_at'
[updatedAtAttribute] => 'updated_at'
[value] => null
[attributes] => [
'beforeInsert' => [
0 => 'created_at'
1 => 'updated_at'
]
'afterInsert' => [
0 => 'updated_at'
]
]
[skipUpdateOnClean] => true
[owner] => common\models\User#1(...)
)
1 => 'evaluateAttributes'
]
1 => null
]
]
'afterInsert' => [
0 => [
0 => [
0 => yii\behaviors\TimestampBehavior#3(...)
1 => 'evaluateAttributes'
]
1 => null
]
]
]
[yii\base\Component:_behaviors] => [
'timestamp' => yii\behaviors\TimestampBehavior#3(...)
]
)
but Yii::$app->user->identity->username is empty
please help