Forums / Developer / Redirecting user to requested URI after login

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?

eZ debug

Timing: Jan 18 2025 02:56:15
Script start
Timing: Jan 18 2025 02:56:15
Module start 'content'
Timing: Jan 18 2025 02:56:16
Module end 'content'
Timing: Jan 18 2025 02:56:16
Script end

Main resources:

Total runtime0.9218 sec
Peak memory usage4,096.0000 KB
Database Queries203

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 588.9766180.8125
Module start 'content' 0.00580.8120 769.7891586.8984
Module end 'content' 0.81780.1039 1,356.6875341.3672
Script end 0.9217  1,698.0547 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.3738210.0002
Check MTime0.00130.1423210.0001
Mysql Total
Database connection0.00060.067510.0006
Mysqli_queries0.851292.34282030.0042
Looping result0.00170.18552010.0000
Template Total0.898197.420.4491
Template load0.00170.186320.0009
Template processing0.896497.243420.4482
Template load and register function0.00010.010910.0001
states
state_id_array0.00070.078010.0007
state_identifier_array0.00070.076120.0004
Override
Cache load0.00150.1574310.0000
Sytem overhead
Fetch class attribute can translate value0.00100.109430.0003
Fetch class attribute name0.00110.120280.0001
XML
Image XML parsing0.00210.224530.0007
class_abstraction
Instantiating content class attribute0.00000.0022120.0000
General
dbfile0.00520.5672330.0002
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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