v1.18.x
Julian Lam 12 years ago
parent 42d1cade23
commit 762cecf1c3

@ -62,7 +62,7 @@ var user = require('./user.js'),
});
} else {
// New User
user.create(handle, null, null, function(err, uid) {
user.create(handle, undefined, undefined, function(err, uid) {
if (err !== null) {
callback(err);
} else {
@ -98,7 +98,7 @@ var user = require('./user.js'),
user.get_uid_by_email(email, function(uid) {
if (!uid) {
user.create(handle, null, email, function(err, uid) {
user.create(handle, undefined, email, function(err, uid) {
if (err !== null) {
callback(err);
} else success(uid);
@ -129,7 +129,7 @@ var user = require('./user.js'),
user.get_uid_by_email(email, function(uid) {
if (!uid) {
user.create(name, null, email, function(err, uid) {
user.create(name, undefined, email, function(err, uid) {
if (err !== null) {
callback(err);
} else success(uid);

@ -14,17 +14,19 @@ var utils = require('./../public/src/utils.js'),
var userslug = utils.slugify(username);
username = username.trim();
email = email.trim();
if (email !== undefined) email = email.trim();
async.parallel([
function(next) {
next(!utils.isEmailValid(email) ? new Error('Invalid Email!') : null);
if (email !== undefined) next(!utils.isEmailValid(email) ? new Error('Invalid Email!') : null);
else next();
},
function(next) {
next(!utils.isUserNameValid(username) ? new Error('Invalid Username!') : null);
},
function(next) {
next(!utils.isPasswordValid(password) ? new Error('Invalid Password!') : null);
if (password !== undefined) next(!utils.isPasswordValid(password) ? new Error('Invalid Password!') : null);
else next();
},
function(next) {
User.exists(userslug, function(exists) {
@ -32,9 +34,11 @@ var utils = require('./../public/src/utils.js'),
});
},
function(next) {
User.isEmailAvailable(email, function(available) {
next(!available ? new Error('Email taken!') : null);
});
if (email !== undefined) {
User.isEmailAvailable(email, function(available) {
next(!available ? new Error('Email taken!') : null);
});
} else next();
}
], function(err, results) {
if (err) return callback(err, 0); // FIXME: Maintaining the 0 for backwards compatibility. Do we need this?
@ -52,7 +56,7 @@ var utils = require('./../public/src/utils.js'),
'location':'',
'birthday':'',
'website':'',
'email' : email,
'email' : email || '',
'signature':'',
'joindate' : Date.now(),
'picture': gravatar,
@ -65,10 +69,12 @@ var utils = require('./../public/src/utils.js'),
});
RDB.set('username:' + username + ':uid', uid);
RDB.set('email:' + email +':uid', uid);
RDB.set('userslug:'+ userslug +':uid', uid);
User.sendConfirmationEmail(email);
if (email !== undefined) {
RDB.set('email:' + email +':uid', uid);
User.sendConfirmationEmail(email);
}
RDB.incr('usercount', function(err, count) {
RDB.handle(err);
@ -80,7 +86,7 @@ var utils = require('./../public/src/utils.js'),
io.sockets.emit('user.latest', {userslug: userslug, username: username});
if (password) {
if (password !== undefined) {
User.hashPassword(password, function(hash) {
User.setUserField(uid, 'password', hash);
});

Loading…
Cancel
Save