-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathforms.py
More file actions
35 lines (27 loc) · 977 Bytes
/
forms.py
File metadata and controls
35 lines (27 loc) · 977 Bytes
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
from allauth.headless.internal.restkit import inputs
from django import forms
from django.utils.translation import gettext_lazy as _
from zango.apps.appauth.models import OldPasswords
class BaseSetPasswordForm(forms.Form):
new_password = forms.CharField(
label=_("New password"),
widget=forms.PasswordInput(
attrs={
"class": "form-control",
"placeholder": "Enter your new password",
"autocomplete": "new-password",
}
),
strip=False,
)
def __init__(self, *args, **kwargs):
self.user = kwargs.pop("user")
super().__init__(*args, **kwargs)
def save(self):
self.user.set_password(self.cleaned_data["new_password"])
self.user.save()
obj = OldPasswords.objects.create(user=self.user)
obj.setPasswords(self.user.password)
obj.save()
class PasswordSetForm(BaseSetPasswordForm, inputs.Input):
pass