Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Fixed Login Form JS Bug (Fixes: #521) (#523)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
justinwray authored and gsingh93 committed Jun 6, 2017
1 parent 5d91ae9 commit 2b1474b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
}
});
}
Expand Down

0 comments on commit 2b1474b

Please sign in to comment.