SEBLOD icon indicating copy to clipboard operation
SEBLOD copied to clipboard

SEBLOD Multisite guest user init problem on J4

Open olivier-nolbert opened this issue 2 years ago • 1 comments

Hi,

The SEBLOD system plugin which manages user guest init on load depending on multisite Yes/No seems to use method (Session) to set the SEBLOD Guest User that is not supported anymore in J4. In Fact, all components gets a user (the SEBLOD Site guest user) where they should have a guest.

The component views use $this->getCurrentUser() which returns a User object with a get('guest') method to check is user is guest.

In the SEBLOD system plugin, the JFactory::getUser() and Session->set() methods are used. JFactory;;getUser() is deprecated and the Session->set() seems to not do the job anymore to set the SEBLOD Site guest user.

Here's what we've done so far to fix the problem on a Multisite (and multilingual) J4.2.9/S4.0RP8 client website :

Add use lines

use Joomla\CMS\User\User; use Joomla\CMS\Factory;

And replacing lines where the user is set :

if ( ! $this->site ) {
		//JFactory::getSession()->set( 'user', JFactory::getUser( $user->id ) );
		Factory::getApplication()->loadIdentity( new User( $user->id ) );
		return;
	}
//$session	=	JFactory::getSession();
//$session->set( 'user', JFactory::getUser( 0 ) );
Factory::getApplication()->loadIdentity( new User() );
// $user			=	new JUser( $this->site->guest );
// $user->guest	=	1;

// $session->set( 'user', $user );
$user			=	new User( $this->site->guest );
$user->set( 'guest', 1 );
Factory::getApplication()->loadIdentity( $user );

This seems to do the job and load the correct user for the whole session and components, like the com_users with the login form which was displaying the 'logout' button before the fix.

Thx,

Olivier

olivier-nolbert avatar Mar 22 '23 08:03 olivier-nolbert

Hi guys, @sebastienheraud Please, What about this issue and the upcoming Seblod 4.1.0 release ?

joomleb avatar Aug 11 '23 17:08 joomleb