|
6 | 6 | from django.utils import timezone |
7 | 7 | from django.utils.module_loading import import_string |
8 | 8 | from django.utils.translation import gettext_lazy as _ |
9 | | -from pydantic import ValidationError as PydanticValidationError |
10 | 9 | from webauthn.helpers.exceptions import ( |
11 | | - InvalidAuthenticationResponse, InvalidRegistrationResponse, |
| 10 | + InvalidAuthenticationResponse, InvalidJSONStructure, |
| 11 | + InvalidRegistrationResponse, |
12 | 12 | ) |
13 | 13 | from webauthn.helpers.parse_authentication_credential_json import ( |
14 | 14 | parse_authentication_credential_json, |
@@ -91,7 +91,7 @@ def _verify_token(self, user, token, device=None): |
91 | 91 |
|
92 | 92 | new_sign_count = verify_authentication_response( |
93 | 93 | device.public_key, device.sign_count, self.webauthn_rp, self.webauthn_origin, challenge, token) |
94 | | - except (PydanticValidationError, WebauthnDevice.DoesNotExist, InvalidAuthenticationResponse) as exc: |
| 94 | + except (InvalidJSONStructure, WebauthnDevice.DoesNotExist, InvalidAuthenticationResponse) as exc: |
95 | 95 | raise forms.ValidationError(_('Entered token is not valid.'), code='invalid_token') from exc |
96 | 96 |
|
97 | 97 | device.sign_count = new_sign_count |
@@ -136,7 +136,7 @@ def clean_token(self): |
136 | 136 |
|
137 | 137 | try: |
138 | 138 | parse_registration_credential_json(token) |
139 | | - except InvalidRegistrationResponse as exc: |
| 139 | + except (InvalidJSONStructure, InvalidRegistrationResponse) as exc: |
140 | 140 | raise forms.ValidationError(_('Entered token is not valid.'), code='invalid_token') from exc |
141 | 141 |
|
142 | 142 | self.cleaned_data = { |
|
0 commit comments