Opened 11 years ago

Closed 5 years ago

#1180 closed defect (wontfix)

After login the user should be redirected to their intended page

Reported by: anonymous Owned by: Anton Graham
Priority: normal Component: AuthRequiredPlugin
Severity: normal Keywords:
Cc: sdyson@…, jfernandez@…, Ryan J Ollos Trac Release: 0.10


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.

Attachments (1)

1180.patch (729 bytes) - added by Sergei Luchko 10 years ago.
The patch to fix the referer parameter of the redirect() method call. tested with Trac 0.10.4

Download all attachments as: .zip

Change History (18)

comment:1 Changed 11 years ago by Anton Graham

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

comment:2 Changed 11 years ago by Anton Graham

Status: newassigned

comment:3 Changed 11 years ago by anonymous

Cc: sdyson@… added; anonymous removed

comment:4 Changed 10 years ago by jfernandez@…

Cc: jfernandez@… added

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 10 years ago by Anton Graham

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 10 years ago by jfernandez@…

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

I go to my trac main page: for example:

Since I require authentication, the application redirects me to: which show me the form to log in.

After sending the username and password the applicationn sends me to: instead of

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

comment:7 Changed 10 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.

so, instead of redirecting to tyhe login page using: req.redirect(req.href.login())

the next instruction can be used:
req.redirect(self.env.href(req.href.login(), 'referer':req.abs_href(req.path_info)}))

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 10 years ago by Anton Graham

Resolution: fixed
Status: assignedclosed

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

comment:9 Changed 10 years ago by Anton Graham

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 10 years ago by Sergei Luchko

Resolution: fixed
Status: closedreopened

[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/

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 10 years ago by Sergei 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 10 years ago by anonymous

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

comment:13 Changed 10 years ago by Anton Graham

Resolution: worksforme
Status: reopenedclosed

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 10 years ago by Sergei Luchko

Attachment: 1180.patch added

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

comment:14 Changed 10 years ago by Sergei Luchko

Resolution: worksforme
Status: closedreopened

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 10 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:16 Changed 8 years ago by Ryan J Ollos

Cc: Ryan J Ollos added

comment:17 Changed 5 years ago by Ryan J Ollos

Resolution: wontfix
Status: reopenedclosed

Plugin is deprecated. See the PermRedirectPlugin.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Anton Graham.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.