diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d30e510..992a1005 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file. - Upgrade to psycopg2 2.8.3 - Add Go usage example - Send monthly reports on 1st of every month, not randomly during the month +- Signup form sets the "auto-login" cookie to avoid an extra click during first login ### Bug Fixes - Prevent double-clicking the submit button in signup form diff --git a/hc/accounts/tests/test_login.py b/hc/accounts/tests/test_login.py index cba61608..7e47a8d5 100644 --- a/hc/accounts/tests/test_login.py +++ b/hc/accounts/tests/test_login.py @@ -26,6 +26,7 @@ class LoginTestCase(BaseTestCase): r = self.client.post("/accounts/login/?next=/integrations/add_slack/", form) self.assertRedirects(r, "/accounts/login_link_sent/") + self.assertIn("auto-login", r.cookies) # The check_token link should have a ?next= query parameter: self.assertEqual(len(mail.outbox), 1) diff --git a/hc/accounts/tests/test_signup.py b/hc/accounts/tests/test_signup.py index 1458c9f7..a6d7ad28 100644 --- a/hc/accounts/tests/test_signup.py +++ b/hc/accounts/tests/test_signup.py @@ -13,6 +13,7 @@ class SignupTestCase(TestCase): r = self.client.post("/accounts/signup/", form) self.assertContains(r, "Account created") + self.assertIn("auto-login", r.cookies) # An user should have been created user = User.objects.get() diff --git a/hc/accounts/views.py b/hc/accounts/views.py index 5f16b4ba..ebe8dd0c 100644 --- a/hc/accounts/views.py +++ b/hc/accounts/views.py @@ -159,7 +159,11 @@ def signup(request): else: ctx = {"form": form} - return render(request, "accounts/signup_result.html", ctx) + response = render(request, "accounts/signup_result.html", ctx) + if ctx.get("created"): + response.set_cookie("auto-login", "1", max_age=300, httponly=True) + + return response def login_link_sent(request):