mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
INSTALL build-essential AND RUN npm install!!!!
bcrypt integration
This commit is contained in:
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
## Installation
|
## 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:
|
Next, obtain all of the dependencies required by NodeBB:
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,9 @@
|
|||||||
"passport-google-oauth": "0.1.5",
|
"passport-google-oauth": "0.1.5",
|
||||||
"passport-facebook": "0.1.5",
|
"passport-facebook": "0.1.5",
|
||||||
"less-middleware": "0.1.11",
|
"less-middleware": "0.1.11",
|
||||||
"marked": "0.2.8"
|
"marked": "0.2.8",
|
||||||
|
"bcrypt": "0.7.5",
|
||||||
|
"node-gyp": "0.9.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
"optionalDependencies": {},
|
"optionalDependencies": {},
|
||||||
|
|||||||
50
src/user.js
50
src/user.js
@@ -3,7 +3,8 @@ var config = require('../config.js'),
|
|||||||
RDB = require('./redis.js'),
|
RDB = require('./redis.js'),
|
||||||
crypto = require('crypto'),
|
crypto = require('crypto'),
|
||||||
emailjs = require('emailjs'),
|
emailjs = require('emailjs'),
|
||||||
emailjsServer = emailjs.server.connect(config.mailer);
|
emailjsServer = emailjs.server.connect(config.mailer),
|
||||||
|
bcrypt = require('bcrypt');
|
||||||
|
|
||||||
(function(User) {
|
(function(User) {
|
||||||
|
|
||||||
@@ -95,30 +96,21 @@ var config = require('../config.js'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
RDB.get('uid:' + uid + ':password', function(user_password) {
|
RDB.get('uid:' + uid + ':password', function(user_password) {
|
||||||
if (password == user_password) {
|
bcrypt.compare(password, user_password, function(err, res) {
|
||||||
// Start, replace, or extend a session
|
if (res === true) {
|
||||||
// RDB.get('sess:' + user.sessionID, function(session) {
|
next({
|
||||||
// if (session !== user.sessionID) {
|
status: "ok",
|
||||||
// RDB.set('sess:' + user.sessionID + ':uid', uid, 60*60*24*14); // Login valid for two weeks
|
user: {
|
||||||
// RDB.set('uid:' + uid + ':session', user.sessionID, 60*60*24*14);
|
uid: uid
|
||||||
// } 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);
|
} else {
|
||||||
// }
|
next({
|
||||||
// });
|
status: 'error',
|
||||||
|
message: 'invalid-password'
|
||||||
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.incr('global:next_user_id', function(uid) {
|
||||||
RDB.set('username:' + username + ':uid', uid);
|
RDB.set('username:' + username + ':uid', uid);
|
||||||
RDB.set('uid:' + uid + ':username', username);
|
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) {
|
if (email) {
|
||||||
RDB.set('uid:' + uid + ':email', email);
|
RDB.set('uid:' + uid + ':email', email);
|
||||||
RDB.set('email:' + email, uid);
|
RDB.set('email:' + email, uid);
|
||||||
|
|||||||
Reference in New Issue
Block a user