From ba1001aac99b10d00c9e9983a0fd95629acee666 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 3 May 2013 13:02:36 -0400 Subject: [PATCH 1/3] fixed alternative login css --- public/css/style.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/css/style.less b/public/css/style.less index 62acb53e10..1169e0eed3 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -231,7 +231,7 @@ footer.footer { li { vertical-align: top; background: transparent; - .none; + display: none; .pointer; &.google { From bceaf67c20eab31183081f12760dcba8c6da3524 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 3 May 2013 13:05:57 -0400 Subject: [PATCH 2/3] INSTALL build-essential AND RUN npm install!!!! bcrypt integration --- README.md | 4 ++-- package.json | 4 +++- src/user.js | 50 ++++++++++++++++++++++++-------------------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 0bd0d383fd..f9ddde4dd2 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ ## Installation -NodeBB is powered by Node.js with a Redis database. They must be installed prior in order for NodeBB to work. +NodeBB is powered by Node.js with a Redis database. They must be installed prior in order for NodeBB to work. `build-essential` exposes the build environment for `bcrypt` compilation. - # apt-get install nodejs redis-server npm + # apt-get install nodejs redis-server npm build-essential Next, obtain all of the dependencies required by NodeBB: diff --git a/package.json b/package.json index 422246b90b..ade3d36f7c 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,9 @@ "passport-google-oauth": "0.1.5", "passport-facebook": "0.1.5", "less-middleware": "0.1.11", - "marked": "0.2.8" + "marked": "0.2.8", + "bcrypt": "0.7.5", + "node-gyp": "0.9.5" }, "devDependencies": {}, "optionalDependencies": {}, diff --git a/src/user.js b/src/user.js index 0b4d22913b..9a7235266c 100644 --- a/src/user.js +++ b/src/user.js @@ -3,7 +3,8 @@ var config = require('../config.js'), RDB = require('./redis.js'), crypto = require('crypto'), emailjs = require('emailjs'), - emailjsServer = emailjs.server.connect(config.mailer); + emailjsServer = emailjs.server.connect(config.mailer), + bcrypt = require('bcrypt'); (function(User) { @@ -95,30 +96,21 @@ var config = require('../config.js'), } RDB.get('uid:' + uid + ':password', function(user_password) { - if (password == user_password) { - // 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); - // } - // }); - - next({ - status: "ok", - user: { - uid: uid - } - }); - } else { - next({ - status: 'error', - message: 'invalid-password' - }); - } + bcrypt.compare(password, user_password, function(err, res) { + if (res === true) { + next({ + status: "ok", + user: { + uid: uid + } + }); + } else { + next({ + status: 'error', + message: 'invalid-password' + }); + } + }); }); }); } @@ -218,7 +210,13 @@ var config = require('../config.js'), RDB.incr('global:next_user_id', function(uid) { RDB.set('username:' + username + ':uid', uid); RDB.set('uid:' + uid + ':username', username); - if (password) RDB.set('uid:' + uid + ':password', password); + if (password) { + bcrypt.genSalt(10, function(err, salt) { + bcrypt.hash(password, salt, function(err, hash) { + RDB.set('uid:' + uid + ':password', hash); + }); + }); + } if (email) { RDB.set('uid:' + uid + ':email', email); RDB.set('email:' + email, uid); From 3c86b43ba3b98b6d9fe98ac49418a448118e1e92 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Fri, 3 May 2013 13:08:16 -0400 Subject: [PATCH 3/3] post count is incrementing when replying --- src/posts.js | 6 ++++-- src/topics.js | 11 ++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/posts.js b/src/posts.js index 5bc0d23410..347fb20c6e 100644 --- a/src/posts.js +++ b/src/posts.js @@ -69,7 +69,7 @@ var RDB = require('./redis.js'), Posts.reply = function(socket, tid, uid, content) { - Posts.create(uid, content, function(pid) { + Posts.create(uid, tid, content, function(pid) { RDB.rpush('tid:' + tid + ':posts', pid); socket.emit('event:alert', { @@ -81,7 +81,7 @@ var RDB = require('./redis.js'), }); }; - Posts.create = function(uid, content, callback) { + Posts.create = function(uid, tid, content, callback) { if (uid === null) return; RDB.incr('global:next_post_id', function(pid) { @@ -90,6 +90,8 @@ var RDB = require('./redis.js'), RDB.set('pid:' + pid + ':uid', uid); RDB.set('pid:' + pid + ':timestamp', new Date().getTime()); + RDB.incr('tid:' + tid + ':postcount'); + // User Details - move this out later RDB.lpush('uid:' + uid + ':posts', pid); diff --git a/src/topics.js b/src/topics.js index 01f1849a3b..e7bf01bb33 100644 --- a/src/topics.js +++ b/src/topics.js @@ -75,7 +75,9 @@ var RDB = require('./redis.js'), timestamp = replies[2]; slug = replies[3]; postcount = replies[4]; - + + + user.get_usernames_by_uids(uid, function(userNames) { var topics = []; @@ -116,8 +118,9 @@ var RDB = require('./redis.js'), }); return; // for now, until anon code is written. } - + RDB.incr('global:next_topic_id', function(tid) { + // Global Topics if (uid == null) uid = 0; if (uid !== null) { @@ -141,7 +144,9 @@ var RDB = require('./redis.js'), RDB.set('tid:' + tid + ':slug', slug); RDB.set('tid:' + tid + ':timestamp', new Date().getTime()); RDB.incr('tid:' + tid + ':postcount'); - + + + RDB.set('topic:slug:' + slug + ':tid', tid); // Posts