@ -2,7 +2,8 @@ var utils = require('./../public/src/utils.js'),
RDB = require ( './redis.js' ) ,
crypto = require ( 'crypto' ) ,
emailjs = require ( 'emailjs' ) ,
emailjsServer = emailjs . server . connect ( config . mailer ) ,
meta = require ( './meta.js' ) ,
emailjsServer = emailjs . server . connect ( meta . config . mailer ) ,
bcrypt = require ( 'bcrypt' ) ,
marked = require ( 'marked' ) ,
notifications = require ( './notifications.js' ) ,
@ -148,13 +149,7 @@ var utils = require('./../public/src/utils.js'),
}
User . getUserFields = function ( uid , fields , callback ) {
RDB . hmgetObject ( 'user:' + uid , fields , function ( err , data ) {
if ( err === null ) {
callback ( data ) ;
} else {
console . log ( err ) ;
}
} ) ;
RDB . hmgetObject ( 'user:' + uid , fields , callback ) ;
}
User . getMultipleUserFields = function ( uids , fields , callback ) {
@ -170,7 +165,9 @@ var utils = require('./../public/src/utils.js'),
} ) ;
function iterator ( uid , callback ) {
User . getUserFields ( uid , fields , function ( userData ) {
User . getUserFields ( uid , fields , function ( err , userData ) {
if ( err )
return callback ( err ) ;
returnData . push ( userData ) ;
callback ( null ) ;
} ) ;
@ -261,7 +258,10 @@ var utils = require('./../public/src/utils.js'),
if ( field === 'email' ) {
var gravatarpicture = User . createGravatarURLFromEmail ( data [ field ] ) ;
User . setUserField ( uid , 'gravatarpicture' , gravatarpicture ) ;
User . getUserFields ( uid , [ 'email' , 'picture' , 'uploadedpicture' ] , function ( userData ) {
User . getUserFields ( uid , [ 'email' , 'picture' , 'uploadedpicture' ] , function ( err , userData ) {
if ( err )
return callback ( err ) ;
RDB . del ( 'email:' + userData [ 'email' ] + ':uid' ) ;
RDB . set ( 'email:' + data [ 'email' ] + ':uid' , uid ) ;
User . setUserField ( uid , field , data [ field ] ) ;
@ -385,7 +385,7 @@ var utils = require('./../public/src/utils.js'),
return ;
}
bcrypt . genSalt ( config . bcrypt _rounds, function ( err , salt ) {
bcrypt . genSalt ( n conf. get( ' bcrypt_rounds') , function ( err , salt ) {
bcrypt . hash ( password , salt , function ( err , hash ) {
callback ( hash ) ;
} ) ;
@ -450,9 +450,9 @@ var utils = require('./../public/src/utils.js'),
}
User . sendConfirmationEmail = function ( email ) {
if ( global. config [ 'email:host' ] && global . config [ 'email:port' ] && global . config [ 'email:from' ] ) {
if ( meta. config [ 'email:host' ] && meta . config [ 'email:port' ] && meta . config [ 'email:from' ] ) {
var confirm _code = utils . generateUUID ( ) ,
confirm _link = config . url + 'confirm/' + confirm _code ,
confirm _link = n conf. get( ' url') + 'confirm/' + confirm _code ,
confirm _email = global . templates [ 'emails/header' ] + global . templates [ 'emails/email_confirm' ] . parse ( { 'CONFIRM_LINK' : confirm _link } ) + global . templates [ 'emails/footer' ] ,
confirm _email _plaintext = global . templates [ 'emails/email_confirm_plaintext' ] . parse ( { 'CONFIRM_LINK' : confirm _link } ) ;
@ -466,10 +466,10 @@ var utils = require('./../public/src/utils.js'),
RDB . set ( confirm _key , email ) ;
RDB . expire ( confirm _key , expiry _time ) ;
// Send intro email w/ confirm code
// Send intro email w/ confirm code
var message = emailjs . message . create ( {
text : confirm _email _plaintext ,
from : config. mailer . from ,
from : meta. config. mailer . from ,
to : email ,
subject : '[NodeBB] Registration Email Verification' ,
attachment : [
@ -625,8 +625,9 @@ var utils = require('./../public/src/utils.js'),
RDB . zrevrange ( 'users:joindate' , 0 , 0 , function ( err , uid ) {
RDB . handle ( err ) ;
User . getUserFields ( uid , [ 'username' , 'userslug' ] , function ( userData ) {
socket . emit ( 'user.latest' , { userslug : userData . userslug , username : userData . username } ) ;
User . getUserFields ( uid , [ 'username' , 'userslug' ] , function ( err , userData ) {
if ( ! err && userData )
socket . emit ( 'user.latest' , { userslug : userData . userslug , username : userData . username } ) ;
} ) ;
} ) ;
}
@ -848,7 +849,7 @@ var utils = require('./../public/src/utils.js'),
var message = emailjs . message . create ( {
text : reset _email _plaintext ,
from : config. mailer ? config . mailer . from : 'localhost@example.org' ,
from : meta. config. mailer ? meta . config . mailer . from : 'localhost@example.org' ,
to : email ,
subject : 'Password Reset Requested' ,
attachment : [