The problem is IF the actionLogin that time identity module object load. after login the actionIndex that time not load the identity module oject .
For Example :-
public function actionIndex()
{
if ( Yii::$app->user->identity->user_type == 'AGENT' ) {
#return Yii::$app->getResponse()->redirect(['my-presence/index']);
return $this->render('index',['url'=>'?r=site/agent-dash-board']);
}
else {
return $this->render('index',['url'=>'?r=site/dash-board']);
}
}
IF i test like actionLogin ( print_r(Yii::$app->user->identity); )
Ouptut :-
appmodelsUsersDetails Object ( [_attributes:yiidbBaseActiveRecord:private] => Array ( [user_id] => 1 [user_type] => ADMIN [user_name] => admin [official_email] => [login_id] => ccpldapbind [password] => 4225a03e57d2b6b66f4fe10bd0cbdcab [last_login] => 2022-12-13 13:56:00 [enabled] => 1 [added_at] => 2018-09-20 13:46:30.927629 [password_lock_status] => [password_lock_count] => 0 [password_locked_on] => 2024-04-01 12:00:00 [password_change_flag] => [last_password_update] => 2018-09-20 [password_released_on] => 2018-09-20 [password_released_by] => [logged_in_status] => [group_id] => 1 [agent_for] => [agent_id] => [application_type] => IRNS CARDS [branch_location] => [sol_id] => ) [_oldAttributes:yiidbBaseActiveRecord:private] => Array ( [user_id] => 1 [user_type] => ADMIN [user_name] => admin [official_email] => [login_id] => ccpldapbind [password] => 4225a03e57d2b6b66f4fe10bd0cbdcab [last_login] => 2022-12-13 13:56:00 [enabled] => 1 [added_at] => 2018-09-20 13:46:30.927629 [password_lock_status] => [password_lock_count] => 0 [password_locked_on] => 2024-04-01 12:00:00 [password_change_flag] => [last_password_update] => 2018-09-20 [password_released_on] => 2018-09-20 [password_released_by] => [logged_in_status] => [group_id] => 1 [agent_for] => [agent_id] => [application_type] => IRNS CARDS [branch_location] => [sol_id] => ) [_related:yiidbBaseActiveRecord:private] => Array ( ) [_relationsDependencies:yiidbBaseActiveRecord:private] => Array ( ) [_errors:yiibaseModel:private] => [_validators:yiibaseModel:private] => [_scenario:yiibaseModel:private] => default [_events:yiibaseComponent:private] => Array ( ) [_eventWildcards:yiibaseComponent:private] => Array ( ) [_behaviors:yiibaseComponent:private] => Array ( ) )
If i test like actionIndex ( print_r(Yii::$app->user->identity);)
output :-
Please find the above image which contains the getting error.
I am Expecting output like this :-
actionIndex ( print_r(Yii::$app->user->identity); )
appmodelsUsersDetails Object ( [_attributes:yiidbBaseActiveRecord:private] => Array ( [user_id] => 1 [user_type] => ADMIN [user_name] => admin [official_email] => [login_id] => ccpldapbind [password] => 4225a03e57d2b6b66f4fe10bd0cbdcab [last_login] => 2022-12-13 13:56:00 [enabled] => 1 [added_at] => 2018-09-20 13:46:30.927629 [password_lock_status] => [password_lock_count] => 0 [password_locked_on] => 2024-04-01 12:00:00 [password_change_flag] => [last_password_update] => 2018-09-20 [password_released_on] => 2018-09-20 [password_released_by] => [logged_in_status] => [group_id] => 1 [agent_for] => [agent_id] => [application_type] => IRNS CARDS [branch_location] => [sol_id] => ) [_oldAttributes:yiidbBaseActiveRecord:private] => Array ( [user_id] => 1 [user_type] => ADMIN [user_name] => admin [official_email] => [login_id] => ccpldapbind [password] => 4225a03e57d2b6b66f4fe10bd0cbdcab [last_login] => 2022-12-13 13:56:00 [enabled] => 1 [added_at] => 2018-09-20 13:46:30.927629 [password_lock_status] => [password_lock_count] => 0 [password_locked_on] => 2024-04-01 12:00:00 [password_change_flag] => [last_password_update] => 2018-09-20 [password_released_on] => 2018-09-20 [password_released_by] => [logged_in_status] => [group_id] => 1 [agent_for] => [agent_id] => [application_type] => IRNS CARDS [branch_location] => [sol_id] => ) [_related:yiidbBaseActiveRecord:private] => Array ( ) [_relationsDependencies:yiidbBaseActiveRecord:private] => Array ( ) [_errors:yiibaseModel:private] => [_validators:yiibaseModel:private] => [_scenario:yiibaseModel:private] => default [_events:yiibaseComponent:private] => Array ( ) [_eventWildcards:yiibaseComponent:private] => Array ( ) [_behaviors:yiibaseComponent:private] => Array ( ) )
Masthan A is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.