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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 02:05:11
Script start
Timing: Jan 18 2025 02:05:11
Module start 'layout'
Timing: Jan 18 2025 02:05:11
Module start 'content'
Timing: Jan 18 2025 02:05:12
Module end 'content'
Timing: Jan 18 2025 02:05:12
Script end

Main resources:

Total runtime0.8333 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0078 587.9141152.6250
Module start 'layout' 0.00780.0041 740.539139.4453
Module start 'content' 0.01190.8200 779.9844547.4922
Module end 'content' 0.83190.0014 1,327.476612.1641
Script end 0.8333  1,339.6406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.4122160.0002
Check MTime0.00130.1559160.0001
Mysql Total
Database connection0.00120.139110.0012
Mysqli_queries0.778193.3716570.0137
Looping result0.00050.0647550.0000
Template Total0.790994.920.3954
Template load0.00230.272120.0011
Template processing0.788694.635720.3943
Template load and register function0.00010.012610.0001
states
state_id_array0.00090.110410.0009
state_identifier_array0.00250.300720.0013
Override
Cache load0.00190.2288200.0001
Sytem overhead
Fetch class attribute can translate value0.00080.090220.0004
Fetch class attribute name0.00150.176450.0003
XML
Image XML parsing0.00100.119920.0005
class_abstraction
Instantiating content class attribute0.00000.001760.0000
General
dbfile0.00280.3340230.0001
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 14
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs