Session data not updated when current user data changes

The support for Joomla 2.5 ended on December 31, 2014. Possible bugs in Joomla 2.5 will not be patched anymore. This forum has been closed. Please update your website to Joomla 3.x

Moderator: ooffick

Forum rules
Please use the official Bug Tracker to report a bug: https://issues.joomla.org
Locked
kompa3
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue Oct 25, 2011 11:48 am

Session data not updated when current user data changes

Post by kompa3 » Tue Nov 01, 2011 9:21 am

I just found out a possible bug in Joomla 1.7.2.

Summary: The session user object is not updated when the current user changes his information (eg. name) in the profile edit view (option=com_users&view=profile).

The steps to reproduce the bug:
1) Log in to the front-end
2) Edit my profile information; change my name ("Old Name" -> "New Name")
3) After saving the profile information, the Login Form module on the left side still remembers my old name "Hi Old Name,"

Ok, if I log out and log in again the situation is corrected.

After examining the code I think there is an error in plugins/user/joomla/joomla.php:
- in onUserLogin() the current user object is stored onto the session
- however, in onUserAfterSave() the user object in the session is not updated
-> in my opinion, it should be updated if the user in concern is the current user in the session

kompa3
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue Oct 25, 2011 11:48 am

Re: Session data not updated when current user data changes

Post by kompa3 » Tue Nov 01, 2011 9:43 am

I think the following could work, inserted into line 114 of plugins/user/joomla/joomla.php:
(last else block of onUserAfterSave)

// Update session data if the current user was updated
$currentUser = JFactory::getUser();
if ($currentUser->id == $user['id'])
{
$session = JFactory::getSession();
$session->set('user', new JUser($currentUser->id)); // Force load from database
}

rainweb
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sat Jan 08, 2011 7:52 pm

Re: Session data not updated when current user data changes

Post by rainweb » Sun Dec 11, 2011 9:24 pm

Thanks kompa3, i was looking for this.

televisi
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Thu Jan 02, 2014 8:36 pm

Re: Session data not updated when current user data changes

Post by televisi » Thu Jan 30, 2014 11:25 am

Hi,

Sorry to revive old post; I suspect this is not working for Joomla 3.2?

I tried your method, unfortunately not working

Thanks

User avatar
DeeEmm
Joomla! Apprentice
Joomla! Apprentice
Posts: 33
Joined: Fri Mar 04, 2011 4:36 am
Contact:

Re: Session data not updated when current user data changes

Post by DeeEmm » Thu Feb 13, 2014 8:16 am

televisi, the hack still works but you need to insert it on a different line.

Insert the code after the line below

// Existing user - nothing to do...yet.

It's about line 153

ihtus
Joomla! Intern
Joomla! Intern
Posts: 67
Joined: Thu Feb 28, 2008 2:30 pm
Location: Canada

Re: Session data not updated when current user data changes

Post by ihtus » Thu Jun 12, 2014 1:25 pm

this worked for me (found here http://forum.joomla.org/viewtopic.php?p=2725238)

Code: Select all

	/libraries/joomla/user/user.php
	
find:
		if (empty($this->_authLevels))
		{
			$this->_authLevels = JAccess::getAuthorisedViewLevels($this->id);
		}

replace with:
		if (empty($this->_authLevels)
			|| $this->_authLevels != JAccess::getAuthorisedViewLevels($this->id)
		)
		{
			$this->_authLevels = JAccess::getAuthorisedViewLevels($this->id);
		}


Locked

Return to “Joomla! 2.5 Bug Reporting”