diff --git a/CHANGES.rst b/CHANGES.rst index d530d4b..0280184 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,7 @@ +0.7.1 +----- +- Removed ``passwd-confirm`` param. + 0.7.0 ----- - Made the /auth view process ``application/json`` instead of ``application/x-www-form-urlencoded`` (that was illogical). diff --git a/hel/templates/home.pt b/hel/templates/home.pt index d5145f2..be4c2d9 100644 --- a/hel/templates/home.pt +++ b/hel/templates/home.pt @@ -80,10 +80,6 @@
- -
- -
diff --git a/hel/tests/test_func.py b/hel/tests/test_func.py index 75e207e..f68962b 100644 --- a/hel/tests/test_func.py +++ b/hel/tests/test_func.py @@ -97,7 +97,6 @@ def test_bad_reg(self): res = self.test_app.post('/', { 'email': '', 'nickname': '', - 'passwd-confirm': '', 'register': True }, status=200) message = res.html.find(id='login-message') @@ -109,7 +108,6 @@ def test_failed_reg_empty_nick(self): 'email': '', 'nickname': '', 'password': '', - 'passwd-confirm': '', 'register': True }, status=200) message = res.html.find(id='login-message') @@ -121,7 +119,6 @@ def test_failed_reg_empty_email(self): 'email': '', 'nickname': self.user['nickname'], 'password': '', - 'passwd-confirm': '', 'register': True }, status=200) message = res.html.find(id='login-message') @@ -133,27 +130,24 @@ def test_failed_reg_empty_password(self): 'email': self.user['email'], 'nickname': self.user['nickname'], 'password': '', - 'passwd-confirm': '', 'register': True }, status=200) message = res.html.find(id='login-message') self.assertIsNotNone(message) self.assertEqual(message.string, Messages.empty_password) - def test_failed_reg_nick_use(self): - data = copy.copy(self.user) - data['register'] = True - data['passwd-confirm'] = 'hi' - res = self.test_app.post('/', data, status=200) - self.assertIsNone(res.html.find(id='log-out')) - message = res.html.find(id='login-message') - self.assertIsNotNone(message) - self.assertEqual(message.string, Messages.password_mismatch) + # def test_failed_reg_nick_use(self): + # data = copy.copy(self.user) + # data['register'] = True + # res = self.test_app.post('/', data, status=200) + # self.assertIsNone(res.html.find(id='log-out')) + # message = res.html.find(id='login-message') + # self.assertIsNotNone(message) + # self.assertEqual(message.string, Messages.password_mismatch) def test_reg_success(self): data = copy.copy(self.user) data['register'] = True - data['passwd-confirm'] = data['password'] res = self.test_app.post('/', data, status=200) message = res.html.find(id='login-message') self.assertIsNotNone(message) @@ -214,7 +208,6 @@ def setUp(self): FunctionalAuthTests.setUp(self) data = copy.copy(self.user) data['register'] = True - data['passwd-confirm'] = data['password'] res = self.test_app.post('/', data, status=200) message = res.html.find(id='login-message') self.assertIsNotNone(message) @@ -333,7 +326,6 @@ def setUp(self): FunctionalAuthTests.setUp(self) data = copy.copy(self.user) data['register'] = True - data['passwd-confirm'] = data['password'] res = self.test_app.post('/', data, status=200) message = res.html.find(id='login-message') self.assertIsNotNone(message) @@ -349,7 +341,6 @@ def test_failed_reg_nick_use(self): 'nickname': 'root', 'email': 'asd', 'password': '...', - 'passwd-confirm': '...', 'register': True }, status=200) self.assertIsNone(res.html.find(id='log-out')) @@ -362,7 +353,6 @@ def test_failed_reg_email_use(self): 'nickname': 'root2', 'email': 'root@your.pc', 'password': '...', - 'passwd-confirm': '...', 'register': True }, status=200) self.assertIsNone(res.html.find(id='log-out')) diff --git a/hel/utils/__init__.py b/hel/utils/__init__.py index d6b10e7..3820a00 100644 --- a/hel/utils/__init__.py +++ b/hel/utils/__init__.py @@ -1,7 +1,7 @@ import json -VERSION = '0.7.0' +VERSION = '0.7.1' def parse_search_phrase(s): diff --git a/hel/views.py b/hel/views.py index 4653606..a695a9f 100644 --- a/hel/views.py +++ b/hel/views.py @@ -138,7 +138,6 @@ def auth(request): nickname = params['nickname'].strip() email = params['email'].strip() password = params['password'].strip() - passwd_confirm = params['passwd-confirm'].strip() except (KeyError, AttributeError): message = Messages.bad_request else: @@ -158,46 +157,43 @@ def auth(request): if user: message = Messages.email_in_use else: - if password != passwd_confirm: - message = Messages.password_mismatch - else: - act_phrase = ''.join( - '{:02x}'.format(x) for x in os.urandom( - request.registry.settings - ['activation.length'])) - act_till = (datetime.datetime.now() + - datetime.timedelta( - seconds=request.registry.settings - ['activation.time'])) - subrequest = Request.blank( - '/users', method='POST', POST=( - str(ModelUser(nickname=nickname, - email=email, - password=pass_hash, - activation_phrase=act_phrase, - activation_till=act_till))), - content_type='application/json') - subrequest.no_permission_check = True - response = request.invoke_subrequest( - subrequest, use_tweens=True) - if response.status_code == 201: - # TODO: send activation email - request.response.status = '200 OK' - return {'message': - Messages.account_created_success, - 'code': 200, - 'title': 'OK', - 'success': True} - else: # pragma: no cover - message = Messages.internal_error - log.error( - 'Could not create a user: subrequest' - ' returned with status code %s!\n' - 'Local variables in frame:%s', - response.status_code, - ''.join(['\n * ' + str(x) + ' = ' + str(y) - for x, y in locals().items()]) - ) + act_phrase = ''.join( + '{:02x}'.format(x) for x in os.urandom( + request.registry.settings + ['activation.length'])) + act_till = (datetime.datetime.now() + + datetime.timedelta( + seconds=request.registry.settings + ['activation.time'])) + subrequest = Request.blank( + '/users', method='POST', POST=( + str(ModelUser(nickname=nickname, + email=email, + password=pass_hash, + activation_phrase=act_phrase, + activation_till=act_till))), + content_type='application/json') + subrequest.no_permission_check = True + response = request.invoke_subrequest( + subrequest, use_tweens=True) + if response.status_code == 201: + # TODO: send activation email + request.response.status = '200 OK' + return {'message': + Messages.account_created_success, + 'code': 200, + 'title': 'OK', + 'success': True} + else: # pragma: no cover + message = Messages.internal_error + log.error( + 'Could not create a user: subrequest' + ' returned with status code %s!\n' + 'Local variables in frame:%s', + response.status_code, + ''.join(['\n * ' + str(x) + ' = ' + str(y) + for x, y in locals().items()]) + ) jexc(HTTPBadRequest, message) @@ -440,8 +436,7 @@ def delete_package(context, request): context.delete() return Response( - status='204 No Content', - content_type='application/json') + status='204 No Content') @view_config(request_method='POST',