Defect #1900

login filter providing incorrect back_url for Redmine installed in sub-directory

Added by Tony Kemp about 9 years ago. Updated almost 9 years ago.

Status:ClosedStart date:2008-09-15
Priority:HighDue date:
Assignee:-% Done:

0%

Category:UI
Target version:0.8
Resolution:Fixed Affected version:

Description

I have Redmine running in a subdirectory on my server (i.e. in '/redmine'). The new require_login filter introduced a bug where the :back_url parameter that it creates does not take into account the relative URL root that this type of installation requires for redirection URLs. I have created a fix for this problem that works for both root installations and sub-directory installations, and I have included a patch below. This patch works for me, but you will want to do some testing to make sure I haven't broken anything.

This error is currently occurring in r1860, first noticed in r1802, though I think the bug was introduced earlier.
Rails: 2.1.0
Ruby: 1.8.6
Database: SQLite 3.4.2

Patch:

app/controllers/application.rb
@@ -81,7 +81,7 @@ class ApplicationController < ActionController::Base

   def require_login
     if !User.current.logged?
-      redirect_to :controller => "account", :action => "login", :back_url => request.request_uri
+      redirect_to :controller => "account", :action => "login", :back_url => request.relative_url_root + request.request_uri
       return false
     end
     true

Associated revisions

Revision 1890
Added by Jean-Philippe Lang about 9 years ago

Fixed: login filter providing incorrect back_url for Redmine installed in sub-directory (#1900).

Revision 1898
Added by Nicolas Chuche about 9 years ago

r18645@gaspard (orig r1887): jplang | 2008-09-20 16:07:52 +0200
Fixed: Roadmap crashes when a version has a due date > 2037.
r18646@gaspard (orig r1888): jplang | 2008-09-21 10:54:02 +0200
Fixed: invalid effective date (eg. 99999-01-01) causes an error on version edition screen.
r18647@gaspard (orig r1889): jplang | 2008-09-21 10:54:50 +0200
Fixes VersionTest class.
r18648@gaspard (orig r1890): jplang | 2008-09-21 14:07:44 +0200
Fixed: login filter providing incorrect back_url for Redmine installed in sub-directory (#1900).
r18649@gaspard (orig r1891): winterheart | 2008-09-21 14:31:34 +0200
de.yml from #1745, thank to Sven Schuchmann and Thomas Löber for contribution
r18650@gaspard (orig r1892): winterheart | 2008-09-21 14:32:16 +0200
#1928, update for Italian language
r18651@gaspard (orig r1893): jplang | 2008-09-21 14:45:22 +0200
Unescape back_url param before calling redirect_to.
r18652@gaspard (orig r1894): jplang | 2008-09-21 15:28:12 +0200
Strip LDAP attribute names before saving (#1890).
r18653@gaspard (orig r1895): jplang | 2008-09-21 20:45:30 +0200
Switch order of current and previous revisions in side-by-side diff (#1903).
r18654@gaspard (orig r1896): jplang | 2008-09-21 22:38:36 +0200
Typo in migration 97 name (#1929).
r18655@gaspard (orig r1897): winterheart | 2008-09-22 16:49:18 +0200
#1921, pt translation

Revision 1903
Added by Jean-Philippe Lang about 9 years ago

Fixes back_url in login filter (#1900).

Revision 1905
Added by Jean-Philippe Lang about 9 years ago

Fixes back_url in login filter (#1900).

History

#1 Updated by Thomas Lecavelier about 9 years ago

  • Target version changed from 0.7.3 to 0.8
  • Maybe should be a patch, rather than a defect
  • Version 0.7.3 is already released, setting to 0.8 (btw: should be a 0.7.x version to gather patches which could be very cool for that branch)

Thank you for the patch! Hoping someone will try it.

#2 Updated by Jean-Philippe Lang about 9 years ago

  • Status changed from New to Closed
  • Resolution set to Fixed

Confirmed and fixed in r1890. Thanks for your patch.

#3 Updated by Go MAEDA about 9 years ago

  • Status changed from Closed to Reopened

After updated to r1890, I began to get incorrect back_url.

The Redmine is running in subdirectory(http://redmine.example.net/subdir/), and Redmine make incorrect back_url(back_url=back_url=%2Fsubdir%2Fsubdir%2F). Directory name appears twice.

Ruby 1.8.6
Rails 2.1.0
CentOS 5
Apache 2.2.3
Passenger 2.0.1

#4 Updated by Jean-Philippe Lang about 9 years ago

A different fix is committed in r1905. Can you give it a try?

#5 Updated by Tony Kemp about 9 years ago

Jean-Philippe Lang wrote:

A different fix is committed in r1905. Can you give it a try?

r1905 works for me. Thanks for this!

#6 Updated by Go MAEDA about 9 years ago

It works fine. Thanks.

#7 Updated by Jean-Philippe Lang almost 9 years ago

  • Status changed from Reopened to Closed

Thanks for the feedback.

Also available in: Atom PDF