-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from izzyjosh/signup-upgrade
Signup upgrade
- Loading branch information
Showing
7 changed files
with
199 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from django.core.exceptions import ValidationError | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
class PasswordCombinationValidator: | ||
def validate(self,password,user=None): | ||
special_char = "@#$_&-+()/?!;:" | ||
status = "" | ||
|
||
if password.isupper() == True: | ||
raise ValidationError(_("Password don't have lowercase letters"), | ||
code="no lowercase", | ||
) | ||
if password.islower() == True: | ||
raise ValidationError(_("Password don't have uppercase letters"), | ||
code="no uppercase", | ||
) | ||
if password.isalpha() ==True: | ||
raise ValidationError(_("Password should not be letters alone"), | ||
code="no numbers", | ||
) | ||
for i in special_char: | ||
if password.find(i) != -1: | ||
status += "1" | ||
|
||
if status == "": | ||
raise ValidationError(_("Password do not contain special characters"), | ||
code="no special characters", | ||
) | ||
|
||
|
||
def get_help_text(self): | ||
return _("the password should be a combination of uppercase,lowercase,number and special symbols") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from django import forms | ||
from django.contrib.auth.forms import UserCreationForm | ||
from django.contrib.auth import get_user_model | ||
|
||
User = get_user_model() | ||
|
||
class CustomUserCreationForm(UserCreationForm): | ||
|
||
def __init__(self,*args,**kwargs): | ||
super().__init__(*args,**kwargs) | ||
|
||
username = forms.CharField( | ||
label = "Username*", | ||
help_text = "", | ||
required = True, | ||
widget = forms.TextInput(attrs={ | ||
"name":"username", | ||
"placeholder":"Username", | ||
}) | ||
) | ||
email = forms.EmailField( | ||
label="Email", | ||
required=True, | ||
widget=forms.TextInput(attrs={ | ||
"name": "email", | ||
"type": "email", | ||
"placeholder": "Email" | ||
}) | ||
) | ||
|
||
password1 = forms.CharField( | ||
label="Password*", | ||
required=True, | ||
help_text = "", | ||
widget=forms.PasswordInput(attrs={ | ||
"type": "password", | ||
"name": "password1", | ||
"id": "password", | ||
"placeholder": "Password" | ||
}) | ||
) | ||
|
||
password2 = forms.CharField( | ||
label="Password Confirmation*", | ||
required=True, | ||
help_text = "", | ||
widget=forms.PasswordInput(attrs={ | ||
"type": "password", | ||
"name": "password2", | ||
"id": "password", | ||
"placeholder": "Password Confirmation" | ||
}) | ||
) | ||
|
||
class Meta: | ||
model = User | ||
fields = ("username","email","password1","password2",) | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters