diff options
author | Tulio Casagrande <tcasagra@thoughtworks.com> | 2017-04-06 11:20:07 -0300 |
---|---|---|
committer | Tulio Casagrande <tcasagra@thoughtworks.com> | 2017-04-06 11:20:07 -0300 |
commit | 934a9409501e24198bad22a504ac4476e2fda03e (patch) | |
tree | 43c83321a1e3abe0f413a4842e8932f481c4bbe7 /service/pixelated/resources | |
parent | af941920c84b1b1ee5f630993eba0d2d3699aa61 (diff) |
[#934] Handle post in a dedicate method
Diffstat (limited to 'service/pixelated/resources')
-rw-r--r-- | service/pixelated/resources/account_recovery_resource.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/service/pixelated/resources/account_recovery_resource.py b/service/pixelated/resources/account_recovery_resource.py index 6e80f360..209a7693 100644 --- a/service/pixelated/resources/account_recovery_resource.py +++ b/service/pixelated/resources/account_recovery_resource.py @@ -66,19 +66,22 @@ class AccountRecoveryResource(BaseResource): request.setResponseCode(INTERNAL_SERVER_ERROR) request.finish() - d = self._validate_password(request) + d = self._handle_post(request) d.addCallbacks(success_response, error_response) return NOT_DONE_YET def _get_post_form(self, request): return json.loads(request.content.getvalue()) - def _validate_password(self, request): + def _validate_password(self, password, confirm_password): + return password == confirm_password and len(password) >= 8 and len(password) <= 9999 + + def _handle_post(self, request): form = self._get_post_form(request) password = form.get('password') - confirmPassword = form.get('confirmPassword') + confirm_password = form.get('confirmPassword') - if password == confirmPassword and len(password) >= 8 and len(password) <= 9999: - return defer.succeed('Done!') + if not self._validate_password(password, confirm_password): + return defer.fail(InvalidPasswordError('The user entered an invalid password or confirmation')) - return defer.fail(InvalidPasswordError('The user entered an invalid password or confirmation')) + return defer.succeed('Done!') |