From 3fbd1b218ea93bfb74603384f600d0828e9e689e Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 1 Sep 2014 21:54:22 +0200 Subject: [PATCH] Fixed double errors in registration --- public_html/js/Presenters/RegistrationPresenter.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/public_html/js/Presenters/RegistrationPresenter.js b/public_html/js/Presenters/RegistrationPresenter.js index 9a7abc4c..0cd531e0 100644 --- a/public_html/js/Presenters/RegistrationPresenter.js +++ b/public_html/js/Presenters/RegistrationPresenter.js @@ -25,7 +25,8 @@ App.Presenters.RegistrationPresenter = function( email: $el.find('[name=email]').val(), }; - validateRegistrationData(registrationData); + if (!validateRegistrationData(registrationData)) + return; api.post('/users', registrationData) .then(function(response) { @@ -61,18 +62,20 @@ App.Presenters.RegistrationPresenter = function( function validateRegistrationData(registrationData) { if (registrationData.userName.length == 0) { messagePresenter.showError($messages, 'User name cannot be empty.'); - return; + return false; } if (registrationData.password.length == 0) { messagePresenter.showError($messages, 'Password cannot be empty.'); - return; + return false; } if (registrationData.password != registrationData.passwordConfirmation) { messagePresenter.showError($messages, 'Passwords must be the same.'); - return; + return false; } + + return true; }; return {