Opened 7 years ago

Closed 14 months ago

After login the user should be redirected to their intended page

Reported by: Owned by: anonymous BladeHawke normal AuthRequiredPlugin normal sdyson@…, jfernandez@…, rjollos 0.10

Description

If I follow a link directly to a ticket for example, I'll get redirected to the login page, then once I log in I'll be sitting at the main trac page. I should be redirected to the ticket I originally tried to go to.

comment:1 Changed 7 years ago by BladeHawke

I'm going to need to look into this (i.e. not a quick fix for me :p)

comment:2 Changed 7 years ago by BladeHawke

• Status changed from new to assigned

comment:4 Changed 6 years ago by jfernandez@…

I have a similar issue but mine it's a little worse, since my trac installation is not the default root of my server after I log in the application redirects me to a page which has nothing to do with trac.

My trac version is 0.11dev.

By the way, is someone working in this issue?

comment:5 Changed 6 years ago by BladeHawke

I am working on it, but the methods used do not seem to easily support tracking the original target page.

The issue from jfernandez is interesting as my plugin does nothing to users who are logged in, unless I am misunderstanding his comment.

comment:6 Changed 6 years ago by jfernandez@…

May be I wasn't clear. My situation is:

I go to my trac main page: for example: http://myserver.example.org/projects/myproject

Since I require authentication, the application redirects me to:

http://myserver.example.org/projects/myproject

That happens only when AuthRequiredPlugin is enabled; if it is disabled, after the login i'll be in the correct place.

comment:7 Changed 6 years ago by jfernandez@…

I've little knowledge on Python and the trac plug ins development but looking at some source code in other files I found something that can help to resolve this issue by using env.href.

the next instruction can be used:

It'll produce something similar to this(when the redirection is done):

After the user logs in, the application will take the user to the_referer_url.

I think this can solve the problem, however there is a little issue when the user logs out because it'll be redirected to the log in page and referer will be the url to the trac section the user was when he/she clicked the log out link. If he decides to log in again using that browser window he will be redirected to that page. Some people can think that's not right.

May be, before doing the redirection it's necessary to ask if the user is loggin out, and in that case the referer is not req.abs_href(req.path_info) but the wiki page or the start page.

comment:8 Changed 6 years ago by BladeHawke

• Resolution set to fixed
• Status changed from assigned to closed

(In [2375]) New redirect method redirects user to original URL after login instead of WikiStart (fixes #1180)
Thanks to jfernandez@…

comment:9 Changed 6 years ago by BladeHawke

If I get a bug report for the other issue, mentioned, I'll add a small handler for that instance. (I might fix it anyway, but I've had a hard week already :p)

comment:10 Changed 6 years ago by luchko@…

• Resolution fixed deleted
• Status changed from closed to reopened

[2462] has fixed #1771, but did not fix #1180.

The problem still exist because {'referer':req.abs_href(req.path_info)} parameter does not work.
See browser:tags/trac-0.10.4/trac/web/api.py#L311.

Instead, I am proposing the other syntax:

req.redirect(https(req.abs_href.login()) + '?referer=' + req.abs_href(req.path_info))


This worked for me.

comment:11 Changed 6 years ago by luchko@…

OOPS! https() is my special function to convert login url from HTTP to HTTPS.

The correct line is:

req.redirect(req.abs_href.login() + '?referer=' + req.abs_href(req.path_info))


comment:12 Changed 6 years ago by anonymous

What is the status on this ticket? I see it was last updated 5 months ago.

comment:13 Changed 6 years ago by BladeHawke

• Resolution set to worksforme
• Status changed from reopened to closed

I had forgotten the spurious reopening of this ticket. As the poster who reopened it noted, [2462] fixed #1771 and not #1180. That would, of course, be because #1180 was fixed by [2375].

Please note that this has not been tested by me on 0.11 at all, nor will it likely be in the near future as I do not have a Trac running anywhere at the moment, nor will I in the foreseeable future. It did work on my installation at the time of the fix and it worked for jfernandez who was needing the fix at the time on his 0.11dev.

Changed 6 years ago by luchko@…

The patch to fix the referer parameter of the redirect() method call. tested with Trac 0.10.4

comment:14 Changed 6 years ago by luchko@…

• Resolution worksforme deleted
• Status changed from closed to reopened

Have you tested it on 0.10 ?

The change [2375] is done for 0.10 branch, so I expect it to be tested with 0.10 version of Trac. Also the ticket is assigned to 0.10 Trac release.

If this change worked for 0.11dev, I think it should be in 0.11 or 0.11dev branch.

[2375] does not work with Trac 0.10, because the function req.redirect() it calls, expect parameter permanent of type boolean. Passing dictionary to this parameter will just evaluate it to True so the redirection will be permanent. Thus, it will not redirect back to the referrer after the login screen.

I tested it on 0.10.4 version and it does not work. To make it work, please apply the patch: ticket:1180:1180.patch

comment:15 Changed 6 years ago by J.Van

I have tested luchko's ticket:1180:1180.patch on v 0.11 and it works fine.
Thank you luchko.

This ticket should be available for close by BladeHawke.

comment:17 Changed 14 months ago by rjollos

• Resolution set to wontfix
• Status changed from reopened to closed

Plugin is deprecated. See the PermRedirectPlugin.

Modify Ticket

Change Properties