mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 03:49:10 +02:00

This involves changing how registration templates are referenced and how the activation email is sent on user's email address change. Signed-off-by: Amber Elliot <amber.n.elliot@intel.com>
35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
# layerindex-web - extended authentication forms
|
|
#
|
|
# Copyright (C) 2018 Intel Corporation
|
|
#
|
|
# Licensed under the MIT license, see COPYING.MIT for details
|
|
|
|
from django import forms
|
|
from captcha.fields import CaptchaField
|
|
from django_registration.forms import RegistrationForm
|
|
from django.contrib.auth.forms import PasswordResetForm
|
|
from django.contrib.auth.models import User
|
|
from django.contrib.auth.hashers import check_password
|
|
|
|
|
|
class CaptchaRegistrationForm(RegistrationForm):
|
|
captcha = CaptchaField(label='Verification', help_text='Please enter the letters displayed for verification purposes', error_messages={'invalid':'Incorrect entry, please try again'})
|
|
|
|
class CaptchaPasswordResetForm(PasswordResetForm):
|
|
captcha = CaptchaField(label='Verification', help_text='Please enter the letters displayed for verification purposes', error_messages={'invalid':'Incorrect entry, please try again'})
|
|
|
|
|
|
class DeleteAccountForm(forms.ModelForm):
|
|
confirm_password = forms.CharField(widget=forms.PasswordInput)
|
|
|
|
class Meta:
|
|
model = User
|
|
fields = ('confirm_password', )
|
|
|
|
def clean(self):
|
|
cleaned_data = super(DeleteAccountForm, self).clean()
|
|
confirm_password = cleaned_data.get('confirm_password')
|
|
if not check_password(confirm_password, self.instance.password):
|
|
self.add_error('confirm_password', 'Password does not match.')
|
|
return cleaned_data
|