switched a bit of logic around, reduce the amount of ldap queries

This commit is contained in:
downhill 2018-10-14 21:45:03 +02:00
parent d98b85391d
commit b5b208b7da

View file

@ -59,12 +59,12 @@ class Register(View):
if username == "" or not username: if username == "" or not username:
return render(request, 'error.html', { 'urlname': urlname, 'service': service, 'error': 'Please supply a username.' } ) return render(request, 'error.html', { 'urlname': urlname, 'service': service, 'error': 'Please supply a username.' } )
# Check to see if username is already taken # Check to see if username is already taken
if check_user_exists(username):
return render(request, 'error.html', { 'urlname': urlname, 'service': service, 'error': 'User already exists.' } )
# isalnum() may be a bit harsh, but is the most logical choice to make sure it's a username we # isalnum() may be a bit harsh, but is the most logical choice to make sure it's a username we
# can use # can use
elif not username.isalnum(): if not username.isalnum():
return render(request, 'error.html', { 'urlname': urlname, 'service': service, 'error': 'Username has to be alphanumeric.' } ) return render(request, 'error.html', { 'urlname': urlname, 'service': service, 'error': 'Username has to be alphanumeric.' } )
elif check_user_exists(username):
return render(request, 'error.html', { 'urlname': urlname, 'service': service, 'error': 'User already exists.' } )
password1 = request.POST.get('password1') password1 = request.POST.get('password1')
password2 = request.POST.get('password2') password2 = request.POST.get('password2')
# check if the supplied passwords match # check if the supplied passwords match