search by fullname

v1.18.x
barisusakli 10 years ago
parent a77a761433
commit db1cc6b8d2

@ -115,7 +115,7 @@ define('forum/users', function() {
notify.html('<i class="fa fa-spinner fa-spin"></i>');
socket.emit('user.search', {query: username}, function(err, data) {
socket.emit('user.search', {query: username, by: $('.search select').val()}, function(err, data) {
if (err) {
reset();
return app.alertError(err.message);

@ -69,7 +69,7 @@ SocketUser.search = function(socket, data, callback) {
if (!socket.uid) {
return callback(new Error('[[error:not-logged-in]]'));
}
user.search({query: data.query}, callback);
user.search({query: data.query, by: data.by}, callback);
};
// Password Reset

@ -21,7 +21,7 @@ var db = require('./database'),
schemaDate, thisSchemaDate,
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
latestSchema = Date.UTC(2015, 0, 8);
latestSchema = Date.UTC(2015, 0, 9);
Upgrade.check = function(callback) {
db.get('schemaDate', function(err, value) {
@ -459,7 +459,7 @@ Upgrade.upgrade = function(callback) {
db.getSortedSetRange('topics:tid', 0, -1, function(err, tids) {
if (err) {
winston.error('[2014/12/20] Error encountered while updating digest settings');
winston.error('[2015/01/08] Error encountered while Updating category topics sorted sets');
return next(err);
}
@ -490,6 +490,41 @@ Upgrade.upgrade = function(callback) {
winston.info('[2015/01/08] Updating category topics sorted sets skipped');
next();
}
},
function(next) {
thisSchemaDate = Date.UTC(2015, 0, 9);
if (schemaDate < thisSchemaDate) {
winston.info('[2015/01/09] Creating fullname:uid hash');
db.getSortedSetRange('users:joindate', 0, -1, function(err, uids) {
if (err) {
winston.error('[2014/01/09] Error encountered while Creating fullname:uid hash');
return next(err);
}
var now = Date.now();
async.eachLimit(uids, 50, function(uid, next) {
db.getObjectFields('user:' + uid, ['fullname'], function(err, userData) {
if (err || !userData || !userData.fullname) {
return next(err);
}
db.setObjectField('fullname:uid', userData.fullname, uid, next);
});
}, function(err) {
if (err) {
winston.error('[2015/01/09] Error encountered while Creating fullname:uid hash');
return next(err);
}
winston.info('[2015/01/09] Creating fullname:uid hash done');
Upgrade.update(thisSchemaDate, next);
});
});
} else {
winston.info('[2015/01/09] Creating fullname:uid hash skipped');
next();
}
}

@ -113,6 +113,8 @@ module.exports = function(User) {
return updateEmail(uid, data.email, next);
} else if (field === 'username') {
return updateUsername(uid, data.username, next);
} else if (field === 'fullname') {
return updateFullname(uid, data.fullname, next);
} else if (field === 'signature') {
data[field] = S(data[field]).stripTags().s;
} else if (field === 'website') {
@ -222,6 +224,30 @@ module.exports = function(User) {
});
}
function updateFullname(uid, newFullname, callback) {
async.waterfall([
function(next) {
User.getUserField(uid, 'fullname', next);
},
function(fullname, next) {
if (newFullname === fullname) {
return callback();
}
db.deleteObjectField('fullname:uid', fullname, next);
},
function(next) {
User.setUserField(uid, 'fullname', newFullname, next);
},
function(next) {
if (newFullname) {
db.setObjectField('fullname:uid', newFullname, uid, next);
} else {
next();
}
}
], callback);
}
User.changePassword = function(uid, data, callback) {
if (!uid || !data || !data.uid) {
return callback(new Error('[[error:invalid-uid]]'));

@ -20,13 +20,10 @@ module.exports = function(User) {
}
var start = process.hrtime();
var key = 'username:uid';
if (by === 'email') {
key = 'email:uid';
}
var key = by + ':uid';
db.getObject(key, function(err, hash) {
if (err) {
if (err || !hash) {
return callback(null, {timing: 0, users:[]});
}

Loading…
Cancel
Save