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 bdedc19
Show file tree
Hide file tree
Showing 2 changed files with 14 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, redir_param="referer"))
return "plainlogin.html", {
"form": AuthenticationForm(),
"referer": req.args.get("referer", ""),
Expand Down
9 changes: 9 additions & 0 deletions DjangoPlugin/tracdjangoplugin/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ 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 bdedc19

Please sign in to comment.