@@ -5510,37 +5510,6 @@ public static function loginAsUser($userId, $checkIfUserCanLoginAs = true)
55105510 // Logout current user
55115511 self ::loginDelete (api_get_user_id ());
55125512
5513- // Reset and set new session data
5514- Session::erase ('_user ' );
5515- Session::erase ('is_platformAdmin ' );
5516- Session::erase ('is_allowedCreateCourse ' );
5517- Session::erase ('_uid ' );
5518-
5519- // Cleaning session variables
5520- $ _user ['firstName ' ] = $ userInfo ['firstname ' ];
5521- $ _user ['lastName ' ] = $ userInfo ['lastname ' ];
5522- $ _user ['mail ' ] = $ userInfo ['email ' ];
5523- $ _user ['official_code ' ] = $ userInfo ['official_code ' ];
5524- $ _user ['picture_uri ' ] = $ userInfo ['picture_uri ' ];
5525- $ _user ['user_id ' ] = $ userId ;
5526- $ _user ['id ' ] = $ userId ;
5527- $ _user ['status ' ] = $ userInfo ['status ' ];
5528-
5529- // Filling session variables with new data
5530- Session::write ('_uid ' , $ userId );
5531- Session::write ('_user ' , $ userInfo );
5532- Session::write ('is_platformAdmin ' , (bool ) self ::is_admin ($ userId ));
5533- Session::write ('is_allowedCreateCourse ' , 1 == $ userInfo ['status ' ]);
5534- // will be useful later to know if the user is actually an admin or not (example reporting)
5535- Session::write ('login_as ' , true );
5536-
5537- Event::registerLog ([
5538- 'tool ' => 'login ' ,
5539- 'tool_id ' => 0 ,
5540- 'tool_id_detail ' => 0 ,
5541- 'info ' => $ userId ,
5542- ]);
5543-
55445513 return true ;
55455514 }
55465515
0 commit comments