closes #286, closes #287

v1.18.x
Baris Soner Usakli 12 years ago
parent b0a37c6ac5
commit af59ff3209

@ -67,6 +67,37 @@ function upgradeUser(uid, callback) {
});
}
function upgradeUserHash(uid, callback) {
user.getUserFields(uid, ['username', 'userslug', 'email'], function(err, userData) {
if(err)
return callback(err);
async.parallel([
function(next) {
if(userData.username)
RDB.hset('username:uid', userData.username, uid, next);
else
next(null);
},
function(next) {
if(userData.userslug)
RDB.hset('userslug:uid', userData.userslug, uid, next);
else
next(null);
},
function(next) {
if(userData.email)
RDB.hset('email:uid', userData.email, uid, next);
else
next(null);
}
], function(err, result) {
callback(err);
});
});
}
function upgradeAdmins(callback) {
Groups.getGidFromName('Administrators', function(err, gid) {
if (!err && !gid) {
@ -80,7 +111,7 @@ function upgradeAdmins(callback) {
Groups.create('Administrators', 'Forum Administrators', next);
}
], function(err, results) {
var gid = results[1].gid;
var gid = results[1].gid;
async.each(results[0], function(uid, next) {
Groups.join(gid, uid, next);
@ -130,6 +161,24 @@ exports.upgrade = function() {
});
},
function upgradeUserHashes(next) {
winston.info('upgrading user hashes');
RDB.zrange('users:joindate', 0, -1, function(err, uids) {
if(err)
return next(err);
async.each(uids, upgradeUserHash, function(err) {
if(!err) {
winston.info('upgraded user hashes');
next(null, null);
} else {
next(err, null);
}
});
});
},
upgradeAdmins
];

@ -76,11 +76,11 @@ var utils = require('./../public/src/utils.js'),
'showemail': 0
});
RDB.set('username:' + username + ':uid', uid);
RDB.set('userslug:'+ userslug +':uid', uid);
RDB.hset('username:uid', username, uid);
RDB.hset('userslug:uid', userslug, uid);
if (email !== undefined) {
RDB.set('email:' + email +':uid', uid);
RDB.hset('email:uid', email, uid);
User.sendConfirmationEmail(email);
}
@ -114,9 +114,10 @@ var utils = require('./../public/src/utils.js'),
console.log('deleting uid ' + uid);
User.getUserData(uid, function(err, data) {
RDB.del('username:' + data['username'] + ':uid');
RDB.del('email:' + data['email'] +':uid');
RDB.del('userslug:'+ data['userslug'] +':uid');
RDB.hdel('username:uid', data['username']);
RDB.hdel('email:uid', data['email']);
RDB.hdel('userslug:uid', data['userslug']);
RDB.del('user:' + uid);
RDB.del('followers:' + uid);
@ -250,8 +251,8 @@ var utils = require('./../public/src/utils.js'),
if(err)
return next(err);
RDB.del('email:' + userData['email'] + ':uid');
RDB.set('email:' + data['email'] + ':uid', uid);
RDB.hdel('email:uid', userData['email']);
RDB.hset('email:uid', data['email'], uid);
User.setUserField(uid, field, data[field]);
if(userData.picture !== userData.uploadedpicture) {
returnData.picture = gravatarpicture;
@ -275,7 +276,7 @@ var utils = require('./../public/src/utils.js'),
}
User.isEmailAvailable = function(email, callback) {
RDB.exists('email:' + email + ':uid' , function(err, exists) {
RDB.hexists('email:uid', email, function(err, exists) {
callback(err, !exists);
});
}
@ -627,7 +628,7 @@ var utils = require('./../public/src/utils.js'),
}
User.get_uid_by_username = function(username, callback) {
RDB.get('username:' + username + ':uid', function(err, data) {
RDB.hget('username::uid', username, function(err, data) {
if (err) {
RDB.handle(err);
}
@ -636,7 +637,7 @@ var utils = require('./../public/src/utils.js'),
};
User.get_uid_by_userslug = function(userslug, callback) {
RDB.get('userslug:' + userslug + ':uid', function(err, data) {
RDB.hget('userslug:uid', userslug, function(err, data) {
if (err) {
RDB.handle(err);
}
@ -683,7 +684,7 @@ var utils = require('./../public/src/utils.js'),
}
User.get_uid_by_email = function(email, callback) {
RDB.get('email:' + email + ':uid', function(err, data) {
RDB.hget('email:uid', email, function(err, data) {
if (err) {
RDB.handle(err);
}

Loading…
Cancel
Save