Skip to content

Commit

Permalink
Fixed #204 -- Fixed broken RSS links in timeline and query pages
Browse files Browse the repository at this point in the history
  • Loading branch information
bmispelon committed Jun 29, 2024
1 parent 75fe130 commit d2d3f11
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions DjangoPlugin/tracdjangoplugin/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ def process_request(self, req):
raise RequestDone

def do_get(self, req):
# Not 100% sure why, but for some links (RSS especially) Trac likes
# to generate URLs pointing to `/login?referer=<the actual link>` when
# the user is already authenticated.
if req.is_authenticated:
req.redirect(self._get_safe_redirect_url(req))
return "plainlogin.html", {
"form": AuthenticationForm(),
"referer": req.args.get("referer", ""),
Expand Down
14 changes: 14 additions & 0 deletions DjangoPlugin/tracdjangoplugin/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@ def test_login_invalid_inactive_user(self):
User.objects.create_user(username="test", password="test", is_active=False)
self.assertLoginFails(username="test", password="test")

def test_login_page_redirects_if_already_logged_in(self):
self.env.config.set("trac", "base_url", "")
request = self.request_factory(
method="GET",
path_info="/login",
args={"referer": "/test"},
authname="admin",
)

with self.assertRaises(RequestDone):
self.component.process_request(request)

self.assertEqual(request.headers_sent["Location"], "/test")


class DjangoDBManagementMiddlewareTestCase(SimpleTestCase):
@classmethod
Expand Down

0 comments on commit d2d3f11

Please sign in to comment.