Browse Source

Rename login_tfa to login_webauthn

pull/456/head
Pēteris Caune 4 years ago
parent
commit
adb7702f39
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
8 changed files with 13 additions and 13 deletions
  1. +1
    -1
      hc/accounts/forms.py
  2. +1
    -1
      hc/accounts/tests/test_check_token.py
  3. +1
    -1
      hc/accounts/tests/test_login.py
  4. +1
    -1
      hc/accounts/tests/test_login_webauthn.py
  5. +1
    -1
      hc/accounts/urls.py
  6. +7
    -7
      hc/accounts/views.py
  7. +0
    -0
      templates/accounts/login_webauthn.html
  8. +1
    -1
      templates/accounts/profile.html

+ 1
- 1
hc/accounts/forms.py View File

@ -135,7 +135,7 @@ class AddCredentialForm(forms.Form):
attestation_object = Base64Field() attestation_object = Base64Field()
class LoginTfaForm(forms.Form):
class WebauthnForm(forms.Form):
credential_id = Base64Field() credential_id = Base64Field()
client_data_json = Base64Field() client_data_json = Base64Field()
authenticator_data = Base64Field() authenticator_data = Base64Field()


+ 1
- 1
hc/accounts/tests/test_check_token.py View File

@ -50,7 +50,7 @@ class CheckTokenTestCase(BaseTestCase):
r = self.client.post(url) r = self.client.post(url)
self.assertRedirects(r, self.checks_url) self.assertRedirects(r, self.checks_url)
def test_it_redirects_to_login_tfa(self):
def test_it_redirects_to_webauthn_form(self):
Credential.objects.create(user=self.alice, name="Alices Key") Credential.objects.create(user=self.alice, name="Alices Key")
r = self.client.post("/accounts/check_token/alice/secret-token/") r = self.client.post("/accounts/check_token/alice/secret-token/")


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

@ -113,7 +113,7 @@ class LoginTestCase(BaseTestCase):
r = self.client.get("/accounts/login/") r = self.client.get("/accounts/login/")
self.assertNotContains(r, "Create Your Account") self.assertNotContains(r, "Create Your Account")
def test_it_redirects_to_login_tfa(self):
def test_it_redirects_to_webauthn_form(self):
Credential.objects.create(user=self.alice, name="Alices Key") Credential.objects.create(user=self.alice, name="Alices Key")
form = {"action": "login", "email": "[email protected]", "password": "password"} form = {"action": "login", "email": "[email protected]", "password": "password"}


hc/accounts/tests/test_login_tfa.py → hc/accounts/tests/test_login_webauthn.py View File


+ 1
- 1
hc/accounts/urls.py View File

@ -3,7 +3,7 @@ from hc.accounts import views
urlpatterns = [ urlpatterns = [
path("login/", views.login, name="hc-login"), path("login/", views.login, name="hc-login"),
path("login/two_factor/", views.login_tfa, name="hc-login-tfa"),
path("login/two_factor/", views.login_webauthn, name="hc-login-webauthn"),
path("logout/", views.logout, name="hc-logout"), path("logout/", views.logout, name="hc-logout"),
path("signup/", views.signup, name="hc-signup"), path("signup/", views.signup, name="hc-signup"),
path("login_link_sent/", views.login_link_sent, name="hc-login-link-sent"), path("login_link_sent/", views.login_link_sent, name="hc-login-link-sent"),


+ 7
- 7
hc/accounts/views.py View File

@ -105,7 +105,7 @@ def _check_2fa(request, user):
if user.credentials.exists(): if user.credentials.exists():
request.session["2fa_user_id"] = user.id request.session["2fa_user_id"] = user.id
path = reverse("hc-login-tfa")
path = reverse("hc-login-webauthn")
redirect_url = request.GET.get("next") redirect_url = request.GET.get("next")
if _allow_redirect(redirect_url): if _allow_redirect(redirect_url):
path += "?next=%s" % redirect_url path += "?next=%s" % redirect_url
@ -223,17 +223,17 @@ def profile(request):
"page": "profile", "page": "profile",
"profile": profile, "profile": profile,
"my_projects_status": "default", "my_projects_status": "default",
"tfa_status": "default",
"2fa_status": "default",
"added_credential_name": request.session.pop("added_credential_name", ""), "added_credential_name": request.session.pop("added_credential_name", ""),
"removed_credential_name": request.session.pop("removed_credential_name", ""), "removed_credential_name": request.session.pop("removed_credential_name", ""),
"credentials": request.user.credentials.order_by("id"), "credentials": request.user.credentials.order_by("id"),
} }
if ctx["added_credential_name"]: if ctx["added_credential_name"]:
ctx["tfa_status"] = "success"
ctx["2fa_status"] = "success"
if ctx["removed_credential_name"]: if ctx["removed_credential_name"]:
ctx["tfa_status"] = "info"
ctx["2fa_status"] = "info"
if request.method == "POST": if request.method == "POST":
if "change_email" in request.POST: if "change_email" in request.POST:
@ -670,7 +670,7 @@ def _check_credential(request, form, credentials):
return True return True
def login_tfa(request):
def login_webauthn(request):
if "2fa_user_id" not in request.session: if "2fa_user_id" not in request.session:
return HttpResponseBadRequest() return HttpResponseBadRequest()
@ -678,7 +678,7 @@ def login_tfa(request):
credentials = [c.unpack() for c in user.credentials.all()] credentials = [c.unpack() for c in user.credentials.all()]
if request.method == "POST": if request.method == "POST":
form = forms.LoginTfaForm(request.POST)
form = forms.WebauthnForm(request.POST)
if not form.is_valid(): if not form.is_valid():
return HttpResponseBadRequest() return HttpResponseBadRequest()
@ -694,4 +694,4 @@ def login_tfa(request):
request.session["state"] = state request.session["state"] = state
ctx = {"options": base64.b64encode(cbor.encode(options)).decode()} ctx = {"options": base64.b64encode(cbor.encode(options)).decode()}
return render(request, "accounts/login_tfa.html", ctx)
return render(request, "accounts/login_webauthn.html", ctx)

templates/accounts/login_tfa.html → templates/accounts/login_webauthn.html View File


+ 1
- 1
templates/accounts/profile.html View File

@ -59,7 +59,7 @@
</div> </div>
</div> </div>
<div class="panel panel-{{ tfa_status }}">
<div class="panel panel-{{ 2fa_status }}">
<div class="panel-body settings-block"> <div class="panel-body settings-block">
<form method="post"> <form method="post">
{% csrf_token %} {% csrf_token %}


Loading…
Cancel
Save