From b5b208b7da9b82111071f7f1a2448f0ba8ffc6e7 Mon Sep 17 00:00:00 2001 From: downhill Date: Sun, 14 Oct 2018 21:45:03 +0200 Subject: [PATCH] switched a bit of logic around, reduce the amount of ldap queries --- dal/dal/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dal/dal/views.py b/dal/dal/views.py index f5a3bdf..5393444 100644 --- a/dal/dal/views.py +++ b/dal/dal/views.py @@ -59,12 +59,12 @@ class Register(View): if username == "" or not username: return render(request, 'error.html', { 'urlname': urlname, 'service': service, 'error': 'Please supply a username.' } ) # 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 # 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.' } ) + elif check_user_exists(username): + return render(request, 'error.html', { 'urlname': urlname, 'service': service, 'error': 'User already exists.' } ) password1 = request.POST.get('password1') password2 = request.POST.get('password2') # check if the supplied passwords match