From e4cc8d6d566b5014b79b2c8c9cff87b5285a102e Mon Sep 17 00:00:00 2001 From: ubuntu Date: Tue, 6 Jun 2017 02:07:29 -0400 Subject: [PATCH] Fixed Login Form JS Bug (Fixes: #521) * Login form JavaScript now properly retrieves and renders errors when invalid login credentials are provided. * Added teamLoginFormError() distinguished from teamNameFormError() and teamTokenFormError(). * Updated teamPasswordFormError() to read the login AJAX response and call the appropriate error function. * This PR fixes the bug identified in Issue #521. --- src/static/js/index.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/static/js/index.js b/src/static/js/index.js index 289fa87f..7a6f4263 100644 --- a/src/static/js/index.js +++ b/src/static/js/index.js @@ -7,6 +7,13 @@ function teamNameFormError() { }); } +function teamLoginFormError() { + $('.el--text')[0].classList.add('form-error'); + $('.fb-form input').on('change', function() { + $('.el--text')[0].classList.remove('form-error'); + }); +} + function teamPasswordFormError(toosimple) { $('.el--text')[1].classList.add('form-error'); if (toosimple) { @@ -115,11 +122,16 @@ function sendIndexRequest(request_data) { goToPage(responseData.redirect); } else { // TODO: Make this a modal - verifyTeamName('register'); if (responseData.message === 'Password too simple') { teamPasswordFormError(true); } - teamTokenFormError(); + if (responseData.message === 'Login failed') { + teamLoginFormError(); + } + if (responseData.message === 'Registration failed') { + teamNameFormError(); + teamTokenFormError(); + } } }); }