diff --git a/hc/accounts/tests/test_check_token.py b/hc/accounts/tests/test_check_token.py index abc837fe..2921540b 100644 --- a/hc/accounts/tests/test_check_token.py +++ b/hc/accounts/tests/test_check_token.py @@ -16,8 +16,7 @@ class CheckTokenTestCase(BaseTestCase): self.assertContains(r, "You are about to log in") def test_it_redirects(self): - r = self.client.post("/accounts/check_token/alice/secret-token/", - follow=True) + r = self.client.post("/accounts/check_token/alice/secret-token/") self.assertRedirects(r, self.checks_url) @@ -30,8 +29,7 @@ class CheckTokenTestCase(BaseTestCase): self.client.login(username="alice@example.org", password="password") # Login again, when already authenticated - r = self.client.post("/accounts/check_token/alice/secret-token/", - follow=True) + r = self.client.post("/accounts/check_token/alice/secret-token/") self.assertRedirects(r, self.checks_url) @@ -49,5 +47,5 @@ class CheckTokenTestCase(BaseTestCase): def test_it_ignores_bad_next_parameter(self): url = "/accounts/check_token/alice/secret-token/?next=/evil/" - r = self.client.post(url, follow=True) + r = self.client.post(url) self.assertRedirects(r, self.checks_url) diff --git a/hc/accounts/tests/test_login.py b/hc/accounts/tests/test_login.py index 37328557..fdc48bdd 100644 --- a/hc/accounts/tests/test_login.py +++ b/hc/accounts/tests/test_login.py @@ -53,7 +53,7 @@ class LoginTestCase(BaseTestCase): "password": "password" } - r = self.client.post("/accounts/login/", form, follow=True) + r = self.client.post("/accounts/login/", form) self.assertRedirects(r, self.checks_url) def test_it_handles_password_login_with_redirect(self): @@ -81,7 +81,7 @@ class LoginTestCase(BaseTestCase): "password": "password" } - r = self.client.post("/accounts/login/?next=/evil/", form, follow=True) + r = self.client.post("/accounts/login/?next=/evil/", form) self.assertRedirects(r, self.checks_url) def test_it_handles_wrong_password(self): diff --git a/hc/accounts/views.py b/hc/accounts/views.py index e99a8457..c914b9c2 100644 --- a/hc/accounts/views.py +++ b/hc/accounts/views.py @@ -80,6 +80,10 @@ def _redirect_after_login(request): if _is_whitelisted(redirect_url): return redirect(redirect_url) + if request.user.project_set.count() == 1: + project = request.user.project_set.first() + return redirect("hc-checks", project.code) + return redirect("hc-index")