Browse Source

Signup form sets the "auto-login" cookie to avoid an extra click during first login

pull/307/head
Pēteris Caune 5 years ago
parent
commit
163b020116
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
4 changed files with 8 additions and 1 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +1
    -0
      hc/accounts/tests/test_login.py
  3. +1
    -0
      hc/accounts/tests/test_signup.py
  4. +5
    -1
      hc/accounts/views.py

+ 1
- 0
CHANGELOG.md View File

@ -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


+ 1
- 0
hc/accounts/tests/test_login.py View File

@ -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)


+ 1
- 0
hc/accounts/tests/test_signup.py View File

@ -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()


+ 5
- 1
hc/accounts/views.py View File

@ -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):


Loading…
Cancel
Save