Coverage for src/django_otp_webauthn/exceptions.py: 100%

40 statements  

« prev     ^ index     » next       coverage.py v7.5.4, created at 2024-06-23 20:15 +0000

1from django.utils.translation import gettext_lazy as _ 

2from rest_framework.exceptions import APIException 

3 

4 

5class OTPWebAuthnApiError(APIException): 

6 pass 

7 

8 

9class InvalidState(OTPWebAuthnApiError): 

10 status_code = 400 

11 default_detail = _("State is missing or invalid. Please begin the operation first before trying to complete it.") 

12 default_code = "invalid_state" 

13 

14 

15class UnprocessableEntity(OTPWebAuthnApiError): 

16 status_code = 422 

17 default_detail = _("Unprocessable Entity") 

18 default_code = "unprocessable_request" 

19 

20 

21class PasswordlessLoginDisabled(OTPWebAuthnApiError): 

22 status_code = 403 

23 default_detail = _("Passwordless login is disabled.") 

24 default_code = "passwordless_login_disabled" 

25 

26 

27class RegistrationDisabled(OTPWebAuthnApiError): 

28 status_code = 403 

29 default_detail = _("Registration is disabled.") 

30 default_code = "registration_disabled" 

31 

32 

33class AuthenticationDisabled(OTPWebAuthnApiError): 

34 status_code = 403 

35 default_detail = _("Authentication is disabled.") 

36 default_code = "authentication_disabled" 

37 

38 

39class LoginRequired(OTPWebAuthnApiError): 

40 status_code = 403 

41 default_detail = _("User is not logged in.") 

42 default_code = "login_required" 

43 

44 

45class UserDisabled(OTPWebAuthnApiError): 

46 status_code = 403 

47 default_detail = _("This user account is marked as disabled.") 

48 default_code = "user_disabled" 

49 

50 

51class CredentialDisabled(OTPWebAuthnApiError): 

52 status_code = 403 

53 default_detail = _("This Passkey has been marked as disabled.") 

54 default_code = "credential_disabled" 

55 

56 

57class CredentialNotFound(OTPWebAuthnApiError): 

58 status_code = 404 

59 default_detail = _("The Passkey you tried to use was not found. Perhaps it was removed?") 

60 default_code = "credential_not_found"