mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
removed the unused login function
This commit is contained in:
@@ -104,7 +104,7 @@ var RDB = require('./redis.js'),
|
|||||||
user.get_gravatars_by_uids([uid], '', function(gravatars) {
|
user.get_gravatars_by_uids([uid], '', function(gravatars) {
|
||||||
var timestamp = new Date().getTime();
|
var timestamp = new Date().getTime();
|
||||||
|
|
||||||
socket.on('topic_' + tid).emit('event:new_post', {
|
socket.in('topic_' + tid).emit('event:new_post', {
|
||||||
'posts' : [
|
'posts' : [
|
||||||
{
|
{
|
||||||
'pid' : pid,
|
'pid' : pid,
|
||||||
@@ -151,7 +151,9 @@ var RDB = require('./redis.js'),
|
|||||||
Posts.hasFavourited(pid, uid, function(hasFavourited) {
|
Posts.hasFavourited(pid, uid, function(hasFavourited) {
|
||||||
if (hasFavourited == false) {
|
if (hasFavourited == false) {
|
||||||
RDB.sadd('pid:' + pid + ':users_favourited', uid);
|
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');
|
RDB.incr('pid:' + pid + ':rep');
|
||||||
|
|
||||||
if (room_id) {
|
if (room_id) {
|
||||||
@@ -167,7 +169,7 @@ var RDB = require('./redis.js'),
|
|||||||
Posts.hasFavourited(pid, uid, function(hasFavourited) {
|
Posts.hasFavourited(pid, uid, function(hasFavourited) {
|
||||||
if (hasFavourited == true) {
|
if (hasFavourited == true) {
|
||||||
RDB.srem('pid:' + pid + ':users_favourited', uid);
|
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');
|
RDB.decr('pid:' + pid + ':rep');
|
||||||
|
|
||||||
if (room_id) {
|
if (room_id) {
|
||||||
|
|||||||
65
src/user.js
65
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) {
|
User.loginViaLocal = function(username, password, next) {
|
||||||
|
|
||||||
if (!username || !password) {
|
if (!username || !password) {
|
||||||
@@ -369,23 +335,26 @@ var config = require('../config.js'),
|
|||||||
};
|
};
|
||||||
|
|
||||||
User.get_user_postdetails = function(uids, callback) {
|
User.get_user_postdetails = function(uids, callback) {
|
||||||
var username = [],
|
|
||||||
rep = [];
|
|
||||||
|
|
||||||
for(var i=0, ii=uids.length; i<ii; i++) {
|
var usernames = [];
|
||||||
username.push('uid:' + uids[i] + ':username');
|
var reputations = [];
|
||||||
rep.push('uid:' + uids[i] + ':rep');
|
|
||||||
}
|
|
||||||
|
|
||||||
RDB.multi()
|
for(var i=0, ii=uids.length; i<ii; ++i) {
|
||||||
.mget(username)
|
|
||||||
.mget(rep)
|
User.getUserFields(uids[i], ['username','reputation'], function(data){
|
||||||
.exec(function(err, replies) {
|
|
||||||
callback({
|
usernames.push(data['username']);
|
||||||
'username': replies[0],
|
reputations.push(data['reputation']);
|
||||||
'rep' : replies[1]
|
|
||||||
});
|
if(usernames.length >= uids.length) {
|
||||||
|
|
||||||
|
callback({
|
||||||
|
'username':usernames,
|
||||||
|
'rep':reputations
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
User.get_uid_by_email = function(email, callback) {
|
User.get_uid_by_email = function(email, callback) {
|
||||||
|
|||||||
@@ -133,11 +133,6 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}),
|
|||||||
modules.user.latest(socket, data);
|
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) {
|
socket.on('user.email.exists', function(data) {
|
||||||
modules.user.email.exists(socket, data.email);
|
modules.user.email.exists(socket, data.email);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user