From 85f903d8b341753b08ac0f573b9409b1a40c5762 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Tue, 28 Apr 2015 10:41:10 +0100 Subject: [PATCH 2/2] signup: fix error documentation, require email email is required by the UI, and if you don't provide it this method raises KeyError anyway. --- pandora/user/views.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pandora/user/views.py b/pandora/user/views.py index 4acf06c..eb9ab62 100644 --- a/pandora/user/views.py +++ b/pandora/user/views.py @@ -146,16 +146,17 @@ def signup(request, data): returns { errors: { username: 'Username already exists', // in case of error - password: 'E-mail address already exists' // in case of error + email: 'E-mail address already exists', // in case of error + password: 'Password can not be empty' // in case of error } user: object // user data, in case of success } see: signin, signout ''' - if 'username' in data and 'password' in data: + if 'username' in data and 'password' in data and 'email' in data: data['username'] = data['username'].strip() - if 'email' in data: - data['email'] = ox.escape_html(data['email']) + data['email'] = ox.escape_html(data['email']) + if User.objects.filter(username__iexact=data['username']).count() > 0: response = json_response({ 'errors': { -- 2.1.0