Redirecting user to requested URI after login

Author Message

David Wirth

Thursday 06 May 2010 1:10:34 pm

Desired behavior:

  1. Anonymous user attempts to navigate to mysite.com/abc but that section is restricted to users of a certain user group, so error module executes and presents login.tpl to user.
  2. User logs in successfully, has necessary view permission.
  3. User is redirected to mysite/abc (rather than to some statically defined redirect target, like the mysite.com root).

This seems like it should be a commonly desired behavior and thus easy to accomplish, but apparently not. I have gathered that kernel/error/view.php puts the login template output into the module result but so far I cannot figure out if the requested URI gets passed in any way to login.tpl and if so how to access it. I could pull it from the session but It looks like the LastAccessesURI variable does not get set to the requested page if the user does not have permission to view the node in question.

I came up with a bunk workaround -- javascript in the pagelayout passes the requested URI back to the RedirectURI hidden element -- but I'm thinking there must be a better solution. Do I have to write a custom error/view module? Or is there a reason I should not be trying to redirect to the requested URI?

Gaetano Giunta

Thursday 06 May 2010 2:09:52 pm

I might be missing something here, but the behavior you describe is exactly the default one...

Principal Consultant International Business
Member of the Community Project Board

David Wirth

Friday 07 May 2010 6:20:46 am

"

I might be missing something here, but the behavior you describe is exactly the default one...

"

I had a lengthy response written out about how the default behavior was the undesirable behavior I previously described but decided before posting I ought to take a look at design/standard/templates/user/login.tpl, and boy howdy was I surprised to see that you are correct. Our ez instance was created and modified by a subcontractor before I started working on it and I guess I just assumed they would not have altered the default, desired behavior to produce the undesirable behavior we have now. I am corresponding with the subcontractor to see what their thinking was on this. Unless they give me a good reason (as in maybe they discovered that the default behavior can somehow produce infinite looping), I'll just undo their redirect modification and mark this thread resolved.

Thanks.

David Wirth

Friday 07 May 2010 7:39:03 am

Yeah, turns out there was a misunderstanding about a requirement -- it was the logout behavior that was supposed to be modified to use the LastAccessesURI entry.

So, um, happy Friday, I guess.

Carry on.

Gaetano Giunta

Friday 07 May 2010 12:59:59 pm

A dirty little secret: the RedirectOnLogoutWithLastAccessURI setting in site.ini file might be enough to get the desired behaviour upon logout, too, with no need to alter templates adding redirects

Principal Consultant International Business
Member of the Community Project Board

David Wirth

Monday 10 May 2010 5:19:24 am

Thanks. After testing it. I've realized that the subcontractor chose not to use that feature because the LastAccessesURI for our main page ends up getting set to the node of a flash component in the page, so when you log out, instead of going back to the main page you get a generic view of the flash component node. I do not yet know how this flash component works but am looking into it. Meanwhile, is there a way to override logout behavior for a single node? Extension?

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 10:42:21
Script start
Timing: Jan 18 2025 10:42:21
Module start 'layout'
Timing: Jan 18 2025 10:42:21
Module start 'content'
Timing: Jan 18 2025 10:42:23
Module end 'content'
Timing: Jan 18 2025 10:42:23
Script end

Main resources:

Total runtime1.5445 sec
Peak memory usage4,096.0000 KB
Database Queries66

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 594.6172152.6406
Module start 'layout' 0.00480.0034 747.257839.4766
Module start 'content' 0.00821.5348 786.7344581.8047
Module end 'content' 1.54300.0015 1,368.539116.1250
Script end 1.5445  1,384.6641 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2084160.0002
Check MTime0.00130.0823160.0001
Mysql Total
Database connection0.00080.049410.0008
Mysqli_queries1.473195.3747660.0223
Looping result0.00060.0413640.0000
Template Total1.512497.920.7562
Template load0.00220.140220.0011
Template processing1.510297.778420.7551
Template load and register function0.00020.014810.0002
states
state_id_array0.00150.094310.0015
state_identifier_array0.00190.123720.0010
Override
Cache load0.00200.1268310.0001
Sytem overhead
Fetch class attribute can translate value0.00060.040120.0003
Fetch class attribute name0.00150.097580.0002
XML
Image XML parsing0.00410.262520.0020
class_abstraction
Instantiating content class attribute0.00000.0025120.0000
General
dbfile0.00360.2347220.0002
String conversion0.00000.000440.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
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
1content/datatype/view/ezxmltags/ol.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ol.tplEdit templateOverride template
1content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 25
 Number of unique templates used: 8

Time used to render debug report: 0.0002 secs