# HG changeset patch # User Brian Neal # Date 1322929515 0 # Node ID b5bd3509e6e6a502ae39181f2174708195e7f1d8 # Parent 2c2df85451124f3762e49ee2ef2db248304a9acb Made some tweaks to the ajax login javascript. Cleared the inputs on failure so someone won't repeatedly try a bad login. Redirect on lockout so the page will refresh. Set focus on the username box after failure for convenience. diff -r 2c2df8545112 -r b5bd3509e6e6 gpp/accounts/static/js/ajax_login.js --- a/gpp/accounts/static/js/ajax_login.js Sat Dec 03 15:07:01 2011 +0000 +++ b/gpp/accounts/static/js/ajax_login.js Sat Dec 03 16:25:15 2011 +0000 @@ -1,5 +1,7 @@ $(function() { var loginError = $('#login-error'); + var userBox = $('#id_username'); + var passBox = $('#id_password'); var loginDialog = $('#login-dialog').dialog({ autoOpen: false, height: 375, @@ -12,8 +14,8 @@ url: '/accounts/login/ajax/', type: 'POST', data: { - username: $('#id_username').val(), - password: $('#id_password').val() + username: userBox.val(), + password: passBox.val() }, dataType: 'json', success: function(data, textStatus) { @@ -28,12 +30,16 @@ } else { loginError.text(data.error).show(); + userBox.val(''); + passBox.val(''); + userBox.focus(); } }, error: function (xhr, textStatus, ex) { if (xhr.status == 403) { loginDialog.dialog("close"); alert("Oops, we are detecting some strange behavior and are blocking this action. If you feel this is an error, please feel free to contact us. Thank you."); + window.location.href = "/"; } else { loginError.text('Oops, an error occurred. If this problem persists, please contact us.').show();