Verify password for registration, force alpha numerics

This commit is contained in:
AndyGrant committed 2018-06-10 23:25:25 -04:00
1 parent 64f492a345
commit 81678b3e3a
3 files changed
+16 -7

No files matched your search

+11 -4
View File
@@ -25,16 +25,23 @@ def register(request):
return render(request, 'register.html', {})
try:
# Verify that the passwords are matching
if request.POST['password1'] != request.POST['password2']:
raise Exception('Passwords Do Not Match')
# Force alpha numeric usernames
if not request.POST['username'].isalnum():
raise Exception('Alpha Numeric Usernames Only')
# Attempt to create and login the new user
user = User.objects.create_user(
request.POST['username'],
request.POST['email'],
request.POST['password']
request.POST['password1']
)
# Login the user and return to index
user.save()
loginUser(request, user)
# Save and log the user in
user.save(); loginUser(request, user)
# Wrap the User in a Profile
profile = Profile()
+5 -3
View File
@@ -9,9 +9,11 @@
{% csrf_token %}
<label type="text">Username</label>
<input type="text" name="username"></br>
<label type="text">Password</label>
<input type="password" name="password"></br>
<label type="text">Email</label>
<label type="text">Create Password</label>
<input type="password" name="password1"></br>
<label type="text">Verify Password</label>
<input type="password" name="password2"></br>
<label type="text">Email Address</label>
<input type="text" name="email"></br>
<input type="submit" name="submit" value="Create User">
</form>
BIN
View File
Binary file not shown.