File: inputs.py

package info (click to toggle)
django-allauth 65.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,672 kB
  • sloc: python: 34,411; javascript: 3,070; xml: 849; makefile: 235; sh: 8
file content (74 lines) | stat: -rw-r--r-- 2,022 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from allauth.account.forms import BaseSignupForm
from allauth.headless.internal.restkit import inputs
from allauth.mfa.base.forms import AuthenticateForm
from allauth.mfa.models import Authenticator
from allauth.mfa.recovery_codes.forms import GenerateRecoveryCodesForm
from allauth.mfa.totp.forms import ActivateTOTPForm
from allauth.mfa.webauthn.forms import (
    AddWebAuthnForm,
    AuthenticateWebAuthnForm,
    LoginWebAuthnForm,
    ReauthenticateWebAuthnForm,
    SignupWebAuthnForm,
)


class AuthenticateInput(AuthenticateForm, inputs.Input):
    pass


class ActivateTOTPInput(ActivateTOTPForm, inputs.Input):
    pass


class GenerateRecoveryCodesInput(GenerateRecoveryCodesForm, inputs.Input):
    pass


class AddWebAuthnInput(AddWebAuthnForm, inputs.Input):
    pass


class CreateWebAuthnInput(SignupWebAuthnForm, inputs.Input):
    pass


class UpdateWebAuthnInput(inputs.Input):
    id = inputs.ModelChoiceField(queryset=Authenticator.objects.none())
    name = inputs.CharField(required=True, max_length=100)

    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop("user")
        super().__init__(*args, **kwargs)
        self.fields["id"].queryset = Authenticator.objects.filter(
            user=self.user, type=Authenticator.Type.WEBAUTHN
        )


class DeleteWebAuthnInput(inputs.Input):
    authenticators = inputs.ModelMultipleChoiceField(
        queryset=Authenticator.objects.none()
    )

    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop("user")
        super().__init__(*args, **kwargs)
        self.fields["authenticators"].queryset = Authenticator.objects.filter(
            user=self.user, type=Authenticator.Type.WEBAUTHN
        )


class ReauthenticateWebAuthnInput(ReauthenticateWebAuthnForm, inputs.Input):
    pass


class AuthenticateWebAuthnInput(AuthenticateWebAuthnForm, inputs.Input):
    pass


class LoginWebAuthnInput(LoginWebAuthnForm, inputs.Input):
    pass


class SignupWebAuthnInput(BaseSignupForm, inputs.Input):
    pass