small fix

This commit is contained in:
Sacha Greif 2015-03-18 09:10:11 +09:00
parent 31dffc58fb
commit 793c6450e7
3 changed files with 46 additions and 42 deletions

View file

@ -1,3 +1,7 @@
## v0.14.4
* Usernames are now case and space insensitive. `John Smith`, `JohnSmith`, and `johnsmith` are now all considered to be the same username (thanks @splendido!).
## v0.14.3 “TableScope”
* Implemented Reactive Table for the Users dashboard (thanks @jshimko!).

View file

@ -19,7 +19,7 @@ var feedSchema = new SimpleSchema({
}
}
},
categories: {
categories: {
type: [String],
label: 'categories',
optional: true,

View file

@ -120,47 +120,6 @@ var migrationsList = {
});
return i;
},
updateUserNames: function () {
var i = 0;
var allUsers = Meteor.users.find();
console.log('> Found '+allUsers.count()+' users.\n');
allUsers.forEach(function(user){
i++;
// Perform the same transforms done by useraccounts with `lowercaseUsernames` set to `true`
var oldUsername = user.username;
var username = user.username;
username = username.trim().replace(/\s+/gm, ' ');
user.profile.username = user.profile.name || username;
delete user.profile.name;
username = username.toLowerCase().replace(/\s+/gm, '');
user.username = username;
if (user.emails.length > 0) {
_.each(user.emails, function(email){
email.address = email.address.toLowerCase().replace(/\s+/gm, '');
});
}
console.log('> Updating user '+user._id+' ('+oldUsername+' -> ' + user.username + ')');
try {
Meteor.users.update(user._id, {
$set: {
emails: user.emails,
profile: user.profile,
username: user.username,
},
});
}
catch (err) {
console.warn('> Unable to convert username ' + user.username + ' to lowercase!');
console.warn('> Please try to fix it by hands!! :(');
}
});
return i;
},
updateUserProfiles: function () {
var i = 0;
var allUsers = Meteor.users.find();
@ -489,6 +448,47 @@ var migrationsList = {
console.log("---------------------");
});
return i;
},
updateUserNames: function () {
var i = 0;
var allUsers = Meteor.users.find();
console.log('> Found '+allUsers.count()+' users.\n');
allUsers.forEach(function(user){
i++;
// Perform the same transforms done by useraccounts with `lowercaseUsernames` set to `true`
var oldUsername = user.username;
var username = user.username;
username = username.trim().replace(/\s+/gm, ' ');
user.profile.username = user.profile.name || username;
delete user.profile.name;
username = username.toLowerCase().replace(/\s+/gm, '');
user.username = username;
if (user.emails.length > 0) {
_.each(user.emails, function(email){
email.address = email.address.toLowerCase().replace(/\s+/gm, '');
});
}
console.log('> Updating user '+user._id+' ('+oldUsername+' -> ' + user.username + ')');
try {
Meteor.users.update(user._id, {
$set: {
emails: user.emails,
profile: user.profile,
username: user.username,
},
});
}
catch (err) {
console.warn('> Unable to convert username ' + user.username + ' to lowercase!');
console.warn('> Please try to fix it by hand!! :(');
}
});
return i;
}
};