diff options
Diffstat (limited to 'static/js/fullscreenmgmt.js')
| -rwxr-xr-x | static/js/fullscreenmgmt.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/static/js/fullscreenmgmt.js b/static/js/fullscreenmgmt.js index 6137238..189b79a 100755 --- a/static/js/fullscreenmgmt.js +++ b/static/js/fullscreenmgmt.js @@ -103,6 +103,21 @@ function initLogin() { '2px solid #30009b'); } +function loginErrorText(resp) { + var code = ""; + try { + code = (resp && resp.responseText) ? ("" + resp.responseText).replace(/^\s+|\s+$/g, "") : ""; + } catch(e) {} + if (code == "NICK_TOO_SHORT") return "Username too short (min 3 characters)."; + if (code == "NICK_TOO_LONG") return "Username too long (max 16 characters)."; + if (code == "NICK_INVALID_CHARS") return "Username can only use letters, numbers, '_' and '-'."; + if (code == "NICK_TAKEN") return "That username is taken/reserved. Try another."; + if (code == "RECENTLY_CREATED") return "Too many new accounts from this IP. Try an existing username."; + if (code == "RECENTLY_MUTED") return "This IP is restricted from creating new accounts. Try an existing username."; + if (code && code != "BAD_LOGIN") return "Couldn't log you in (" + code + ")."; + return "Couldn't log you in :( Try a different username."; +} + function showLogin() { $('#nickInput').val(''); $('#passwordInput').val(''); @@ -115,9 +130,9 @@ function login() { $('#spinner').show(); $('input').attr('disabled', 'disabled'); var nick = $('#nickInput').val(); - var password = $('#passwordInput').val(); + var password = $('#passwordInput').val() || ''; var rememberme = $('#remembermeInput').attr('checked') ? 'yes' : ''; - var hash = hex_sha1(nick + '$' + password + '$dumpfm'); + var hash = password ? hex_sha1(nick + '$' + password + '$dumpfm') : ''; var onSuccess = function(json) { if (typeof pageTracker !== 'undefined') { @@ -131,7 +146,7 @@ function login() { var onError = function(resp, textStatus, errorThrown) { $('#spinner').hide(); $('input').removeAttr('disabled'); - $('#errormsg').text("Couldn't log you in :( Bad password?"); + $('#errormsg').text(loginErrorText(resp)); } $.ajax({ @@ -182,4 +197,4 @@ $(function() { $('#memelogo').stop(true, false).animate({opacity: 1.0}, "fast").delay(LogoFadeDelay).animate({opacity: 0}, "slow"); }); $('#memelogo').delay(LogoFadeDelay).animate({opacity: 0}, "slow"); -});
\ No newline at end of file +}); |
