Beispiel #1
0
class ResetPasswordKeyForm(ChangePasswordMixin, forms.Form):

    password = allauth_forms.SetPasswordField(label=_("New Password"))

    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop('user', None)
        self.temp_key = kwargs.pop('temp_key', None)
        super().__init__(*args, **kwargs)
Beispiel #2
0
class ChangePasswordForm(ChangePasswordMixin, allauth_forms.UserForm):

    oldpassword = allauth_forms.PasswordField(label=_("Current Password"))
    password = allauth_forms.SetPasswordField(label=_("New Password"))

    def clean_oldpassword(self):
        if not self.user.check_password(self.cleaned_data.get('oldpassword')):
            raise forms.ValidationError(
                _("Please type your current"
                  " password."))
        return self.cleaned_data['oldpassword']
Beispiel #3
0
class SetPasswordForm(forms.Form):

    password = allauth_forms.SetPasswordField(label="New Password")

    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop("user", None)
        self.temp_key = kwargs.pop("temp_key", None)
        super().__init__(*args, **kwargs)

    def save(self):
        allauth_forms.get_adapter().set_password(self.user,
                                                 self.cleaned_data['password'])