Forums / Developer / Login and siteaccess change

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

Login and siteaccess change

Author Message

Maxime Thomas

Wednesday 18 July 2007 9:39:20 am

Hi !

I would like to do this from a specific tab in the back office : redirect to a front office siteaccess and in the meanwhile force the login to a specific user without knowing the user's password.

I've tried the following code in a module :

$user =& eZUser::fetchByEmail($email);

$siteAccess = "cse";
eZSys::clearAccessPath();
eZSys::addAccessPath( $siteAccess );

$user->loginCurrent();
    		    		
$Module->redirectTo("/");

But it doesn't seem to work. I'm redirected but not logged.

Has someone got an idea ? Is it the wrong way ?

eZMax

Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

Maxime Thomas

Wednesday 18 July 2007 10:34:51 am

The solution !

//Includes
include_once( "lib/ezutils/classes/ezsession.php");
include_once( "access.php");

//Changing the siteaccess
$access=array("name"=>"cse", "type"=>EZ_ACCESS_TYPE_URI);
eZSys::clearAccessPath();
changeAccess($access);

//Creating a new session for the currently login user
eZSessionStop();
eZSessionStart();			

//Regenerate the id of the session and Login
session_regenerate_id();
eZLDAPUser::loginUser($email, '', false, true);

//Redirect
$Module->redirectTo("/");

Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

H-Works Agency

Wednesday 06 July 2011 7:09:47 am

Hi,

I tried your technique but its not working for me.

What is the method to enable a user on site A to execute a Exponential method that would log him on site B ?

EZP is Great