mirror of
https://github.com/TrentSPalmer/trentpalmerdotorg.git
synced 2024-11-24 10:21:31 -08:00
update accounts/forms.py
This commit is contained in:
parent
31d5d6646a
commit
f82131855f
@ -1,7 +1,7 @@
|
|||||||
from django.contrib.auth.forms import ValidationError, UsernameField, UserCreationForm
|
from django.contrib.auth.forms import ValidationError, UsernameField, UserCreationForm
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django import forms
|
from django import forms
|
||||||
from .models import Account, EmailWhiteList
|
from .models import Account, EmailWhiteList, twitter_handle_validator
|
||||||
|
|
||||||
|
|
||||||
class EnableTotpForm(forms.ModelForm):
|
class EnableTotpForm(forms.ModelForm):
|
||||||
@ -58,7 +58,7 @@ class EditProfileForm(forms.Form):
|
|||||||
|
|
||||||
first_name = UsernameField(required=False)
|
first_name = UsernameField(required=False)
|
||||||
last_name = UsernameField(required=False)
|
last_name = UsernameField(required=False)
|
||||||
twitter_handle = forms.CharField(max_length=64)
|
twitter_handle = forms.CharField(max_length=64, validators=[twitter_handle_validator])
|
||||||
|
|
||||||
password = forms.CharField(
|
password = forms.CharField(
|
||||||
label="confirm password",
|
label="confirm password",
|
||||||
@ -75,8 +75,14 @@ class EditProfileForm(forms.Form):
|
|||||||
email = self.cleaned_data.get('email')
|
email = self.cleaned_data.get('email')
|
||||||
first_name = self.cleaned_data.get('first_name')
|
first_name = self.cleaned_data.get('first_name')
|
||||||
last_name = self.cleaned_data.get('last_name')
|
last_name = self.cleaned_data.get('last_name')
|
||||||
|
if 'password' in self.cleaned_data:
|
||||||
password = self.cleaned_data["password"]
|
password = self.cleaned_data["password"]
|
||||||
|
else:
|
||||||
|
password = ''
|
||||||
|
if 'twitter_handle' in self.cleaned_data:
|
||||||
t_handle = self.cleaned_data['twitter_handle']
|
t_handle = self.cleaned_data['twitter_handle']
|
||||||
|
else:
|
||||||
|
t_handle = ''
|
||||||
if not self.user.check_password(password):
|
if not self.user.check_password(password):
|
||||||
raise ValidationError("password is incorrect.")
|
raise ValidationError("password is incorrect.")
|
||||||
if email != self.user.email:
|
if email != self.user.email:
|
||||||
|
Loading…
Reference in New Issue
Block a user