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()