Ticket #1180 (reopened defect)

Opened 2 years ago

Last modified 10 months ago

After login the user should be redirected to their intended page

Reported by: anonymous Assigned to: BladeHawke
Priority: normal Component: AuthRequiredPlugin
Severity: normal Keywords:
Cc: sdyson@msxi-euro.com, jfernandez@ist.psu.edu Trac Release: 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.

Attachments

1180.patch (0.7 kB) - added by luchko@mail.ru on 01/20/08 16:04:56.
The patch to fix the referer parameter of the redirect() method call. tested with Trac 0.10.4

Change History

02/09/07 18:54:58 changed by BladeHawke

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

02/09/07 18:55:02 changed by BladeHawke

  • status changed from new to assigned.

02/14/07 02:28:07 changed by anonymous

  • cc set to sdyson@msxi-euro.com.

07/03/07 14:13:48 changed by jfernandez@ist.psu.edu

  • cc changed from sdyson@msxi-euro.com to sdyson@msxi-euro.com, jfernandez@ist.psu.edu.

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?

07/03/07 14:22:41 changed 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.

07/03/07 15:49:49 changed by jfernandez@ist.psu.edu

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/login which show me the form to log in.

After sending the username and password the applicationn sends me to:
http://myserver.example.org/ instead of
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.

07/03/07 16:16:07 changed by jfernandez@ist.psu.edu

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): http://myserver.example.org/projects/myproject/login?referer=the_referer_url

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.

07/03/07 17:45:58 changed by BladeHawke

  • status changed from assigned to closed.
  • resolution set to fixed.

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

07/03/07 17:49:18 changed 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)

08/07/07 14:04:00 changed by luchko@mail.ru

  • status changed from closed to reopened.
  • resolution deleted.

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

08/08/07 03:39:00 changed by luchko@mail.ru

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))

01/18/08 14:10:08 changed by anonymous

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

01/19/08 23:31:25 changed by BladeHawke

  • status changed from reopened to closed.
  • resolution set to worksforme.

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.

01/20/08 16:04:56 changed by luchko@mail.ru

  • attachment 1180.patch added.

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

01/20/08 16:06:32 changed by luchko@mail.ru

  • status changed from closed to reopened.
  • resolution deleted.

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

02/06/08 21:52:17 changed 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.


Add/Change #1180 (After login the user should be redirected to their intended page)




Change Properties
Action