From 9b43f80ff8e5badcfaf74dbbedc0b57ef35b38b1 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Tue, 25 Jun 2013 20:55:02 -0400 Subject: [PATCH] changed login to ajax added error message for incorret login, closes #36 --- public/src/forum/login.js | 27 +++++++++++++++++++++++++++ public/templates/login.tpl | 8 ++++++-- src/routes/authentication.js | 7 +++---- src/webserver.js | 5 ++++- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/public/src/forum/login.js b/public/src/forum/login.js index ff203625ab..6e83c0b9f2 100644 --- a/public/src/forum/login.js +++ b/public/src/forum/login.js @@ -11,4 +11,31 @@ document.location.href = target.getAttribute('data-url'); } }); + + + $('#login').on('click', function() { + + var loginData = { + 'username': $('#username').val(), + 'password': $('#password').val(), + '_csrf': $('#csrf-token').val() + }; + + $.ajax({ + type: "POST", + url: '/login', + data: loginData, + success: function(data, textStatus, jqXHR) { + $('#login-error-notify').hide(); + window.location.replace("/"); + }, + error : function(data, textStatus, jqXHR) { + $('#login-error-notify').show().delay(1000).fadeOut(250); + }, + dataType: 'json' + }); + + return false; + }); + }()); diff --git a/public/templates/login.tpl b/public/templates/login.tpl index 33b91ae51e..4cf156f7a6 100644 --- a/public/templates/login.tpl +++ b/public/templates/login.tpl @@ -6,13 +6,17 @@ Failed Login Attempt

-
+ +

- +   Forgot Password?
+ + Invalid username/password
+

Alternative Logins