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
-
+
+ Invalid username/password
+
Alternative Logins
diff --git a/src/routes/authentication.js b/src/routes/authentication.js
index 3098b81cc8..4176b1e734 100644
--- a/src/routes/authentication.js
+++ b/src/routes/authentication.js
@@ -129,10 +129,9 @@
});
- app.post('/login', passport.authenticate('local', {
- successRedirect: '/',
- failureRedirect: '/login'
- }));
+ app.post('/login', passport.authenticate('local'), function(req, res) {
+ res.json({success:1});
+ });
app.post('/register', function(req, res) {
user_module.create(req.body.username, req.body.password, req.body.email, function(err, uid) {
diff --git a/src/webserver.js b/src/webserver.js
index 820cf3ea78..68a4f51601 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -91,7 +91,10 @@ var express = require('express'),
app.get('/' + route, function(req, res) {
if ((route === 'login' || route ==='register') && (req.user && req.user.uid > 0)) {
- res.redirect('/account');
+
+ user.getUserField(req.user.uid, 'userslug', function(userslug) {
+ res.redirect('/users/'+userslug);
+ });
return;
}