Forums / Developer / Login and siteaccess change

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 ezpublish method that would log him on site B ?

EZP is Great