Skip to content

Node.js based forum software built for the modern web

removed the unused login function

Baris Soner Usakli54b4c55dfc10
diff --git a/src/posts.js b/src/posts.js
index 5dc9ffc52b..05783591ab 100644
--- a/src/posts.js
+++ b/src/posts.js
@@ -104,7 +104,7 @@ var RDB = require('./redis.js'),
user.get_gravatars_by_uids([uid], '', function(gravatars) {
var timestamp = new Date().getTime();
- socket.on('topic_' + tid).emit('event:new_post', {
+ socket.in('topic_' + tid).emit('event:new_post', {
'posts' : [
{
'pid' : pid,
@@ -151,7 +151,9 @@ var RDB = require('./redis.js'),
Posts.hasFavourited(pid, uid, function(hasFavourited) {
if (hasFavourited == false) {
RDB.sadd('pid:' + pid + ':users_favourited', uid);
- RDB.incr('uid:' + uid_of_poster + ':rep');
+
+ RDB.db.hincrby(String(uid_of_poster), 'reputation', 1);
+
RDB.incr('pid:' + pid + ':rep');
if (room_id) {
@@ -167,7 +169,7 @@ var RDB = require('./redis.js'),
Posts.hasFavourited(pid, uid, function(hasFavourited) {
if (hasFavourited == true) {
RDB.srem('pid:' + pid + ':users_favourited', uid);
- RDB.decr('uid:' + uid_of_poster + ':rep');
+ RDB.db.hincrby(String(uid_of_poster), 'reputation', -1);
RDB.decr('pid:' + pid + ':rep');
if (room_id) {
diff --git a/src/user.js b/src/user.js
index e25695be40..45c6b8cc5f 100644
--- a/src/user.js
+++ b/src/user.js
@@ -62,40 +62,6 @@ var config = require('../config.js'),
}
};
- User.login = function(socket, user) {
- console.log("THIS IS USED");
-
-
- if (user.username == null || user.password == null) {
- return socket.emit('user.login', {'status': 0, 'message': 'Missing fields'});
- }
-
- RDB.get('username:' + user.username + ':uid', function(uid) {
- if (uid == null) {
- return socket.emit('user.login', {'status': 0, 'message': 'Username does not exist.'});
- }
-
- RDB.get('uid:' + uid + ':password', function(password) {
- if (user.password != password) {
- return socket.emit('user.login', {'status': 0, 'message': 'Incorrect username / password combination.'});
- } else {
- // Start, replace, or extend a session
- RDB.get('sess:' + user.sessionID, function(session) {
- if (session !== user.sessionID) {
- RDB.set('sess:' + user.sessionID + ':uid', uid, 60*60*24*14); // Login valid for two weeks
- RDB.set('uid:' + uid + ':session', user.sessionID, 60*60*24*14);
- } else {
- RDB.expire('sess:' + user.sessionID + ':uid', 60*60*24*14); // Defer expiration to two weeks from now
- RDB.expire('uid:' + uid + ':session', 60*60*24*14);
- }
- });
-
- return socket.emit('user.login', {'status': 1, 'message': 'Logged in!'});
- }
- });
- });
- };
-
User.loginViaLocal = function(username, password, next) {
if (!username || !password) {
@@ -369,23 +335,26 @@ var config = require('../config.js'),
};
User.get_user_postdetails = function(uids, callback) {
- var username = [],
- rep = [];
-
- for(var i=0, ii=uids.length; i<ii; i++) {
- username.push('uid:' + uids[i] + ':username');
- rep.push('uid:' + uids[i] + ':rep');
- }
- RDB.multi()
- .mget(username)
- .mget(rep)
- .exec(function(err, replies) {
- callback({
- 'username': replies[0],
- 'rep' : replies[1]
- });
+ var usernames = [];
+ var reputations = [];
+
+ for(var i=0, ii=uids.length; i<ii; ++i) {
+
+ User.getUserFields(uids[i], ['username','reputation'], function(data){
+
+ usernames.push(data['username']);
+ reputations.push(data['reputation']);
+
+ if(usernames.length >= uids.length) {
+
+ callback({
+ 'username':usernames,
+ 'rep':reputations
+ });
+ }
});
+ }
}
User.get_uid_by_email = function(email, callback) {
diff --git a/src/websockets.js b/src/websockets.js
index 1cf7a6c324..8eaf559df1 100644
--- a/src/websockets.js
+++ b/src/websockets.js
@@ -133,11 +133,6 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}),
modules.user.latest(socket, data);
});
- socket.on('user.login', function(data) {
- data.sessionID = sessionID;
- modules.user.login(socket, data);
- });
-
socket.on('user.email.exists', function(data) {
modules.user.email.exists(socket, data.email);
});