mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
Merge branch 'lowercase-usernames' into devel
This commit is contained in:
commit
31dffc58fb
10 changed files with 68 additions and 24 deletions
|
@ -46,7 +46,7 @@ rajit:bootstrap3-datepicker
|
||||||
bengott:avatar
|
bengott:avatar
|
||||||
jparker:gravatar
|
jparker:gravatar
|
||||||
tap:i18n
|
tap:i18n
|
||||||
useraccounts:unstyled@1.4.0
|
useraccounts:unstyled@1.8.1
|
||||||
tsega:bootstrap3-datetimepicker@3.1.3_1
|
tsega:bootstrap3-datetimepicker@3.1.3_1
|
||||||
momentjs:moment
|
momentjs:moment
|
||||||
aslagle:reactive-table
|
aslagle:reactive-table
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template name="userAccount">
|
<template name="userAccount">
|
||||||
<div class="grid-small grid-module dialog user-edit">
|
<div class="grid-small grid-module dialog user-edit">
|
||||||
|
|
||||||
{{#if profileIncomplete}}
|
{{#if profileIncomplete}}
|
||||||
<div>
|
<div>
|
||||||
{{_ "please_complete_your_profile_below_before_continuing"}}
|
{{_ "please_complete_your_profile_below_before_continuing"}}
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label>{{_ "display_name"}}</label>
|
<label>{{_ "display_name"}}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input name="name" type="text" value="{{profile.name}}" />
|
<input name="name" type="text" value="{{profile.username}}" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -100,4 +100,4 @@
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -47,7 +47,7 @@ Template[getTemplate('userAccount')].events({
|
||||||
var email = $target.find('[name=email]').val();
|
var email = $target.find('[name=email]').val();
|
||||||
var user = this;
|
var user = this;
|
||||||
var update = {
|
var update = {
|
||||||
"profile.name": name,
|
"profile.username": name,
|
||||||
"profile.slug": slugify(name),
|
"profile.slug": slugify(name),
|
||||||
"profile.bio": $target.find('[name=bio]').val(),
|
"profile.bio": $target.find('[name=bio]').val(),
|
||||||
"profile.email": email,
|
"profile.email": email,
|
||||||
|
|
|
@ -7,7 +7,7 @@ Template[getTemplate('users')].helpers({
|
||||||
fields: [
|
fields: [
|
||||||
{ key: 'avatar', label: '', tmpl: Template.users_list_avatar, sortable: false },
|
{ key: 'avatar', label: '', tmpl: Template.users_list_avatar, sortable: false },
|
||||||
{ key: 'username', label: 'Username', tmpl: Template.users_list_username },
|
{ key: 'username', label: 'Username', tmpl: Template.users_list_username },
|
||||||
{ key: 'profile.name', label: 'Display Name' },
|
{ key: 'profile.username', label: 'Display Name' },
|
||||||
{ key: 'profile.email', label: 'Email', tmpl: Template.users_list_email },
|
{ key: 'profile.email', label: 'Email', tmpl: Template.users_list_email },
|
||||||
{ key: 'createdAt', label: 'Member Since', tmpl: Template.users_list_created_at, sort: 'descending' },
|
{ key: 'createdAt', label: 'Member Since', tmpl: Template.users_list_created_at, sort: 'descending' },
|
||||||
{ key: 'postCount', label: 'Posts' },
|
{ key: 'postCount', label: 'Posts' },
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{_ "name"}}</td>
|
<td>{{_ "name"}}</td>
|
||||||
<td>{{profile.name}}</td>
|
<td>{{profile.username}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{_ "member_since"}}:</td>
|
<td>{{_ "member_since"}}:</td>
|
||||||
|
@ -52,4 +52,4 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
/* global
|
||||||
|
AccountsTemplates: false,
|
||||||
|
getSetting: false
|
||||||
|
*/
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
// AccountsTemplates configuration
|
// AccountsTemplates configuration
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
|
@ -26,8 +31,6 @@ AccountsTemplates.addField({
|
||||||
required: true,
|
required: true,
|
||||||
re: /.+@(.+){2,}\.(.+){2,}/,
|
re: /.+@(.+){2,}\.(.+){2,}/,
|
||||||
errStr: 'error.accounts.Invalid email',
|
errStr: 'error.accounts.Invalid email',
|
||||||
trim: true,
|
|
||||||
lowercase: true
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AccountsTemplates.removeField('password');
|
AccountsTemplates.removeField('password');
|
||||||
|
@ -39,14 +42,13 @@ AccountsTemplates.addField({
|
||||||
errStr: 'error.minChar'
|
errStr: 'error.minChar'
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
AccountsTemplates.addField({
|
||||||
AccountsTemplates.addField({
|
_id: 'username_and_email',
|
||||||
_id: 'username_and_email',
|
type: 'text',
|
||||||
type: 'text',
|
required: true,
|
||||||
displayName: 'Name or Email',
|
displayName: 'usernameOrEmail',
|
||||||
placeholder: 'name or email',
|
placeholder: 'usernameOrEmail',
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//Routes
|
//Routes
|
||||||
|
@ -67,6 +69,7 @@ AccountsTemplates.configure({
|
||||||
showForgotPasswordLink: true,
|
showForgotPasswordLink: true,
|
||||||
confirmPassword: false,
|
confirmPassword: false,
|
||||||
overrideLoginErrors: true,
|
overrideLoginErrors: true,
|
||||||
|
lowercaseUsername: true,
|
||||||
|
|
||||||
negativeFeedback: false,
|
negativeFeedback: false,
|
||||||
positiveFeedback: false,
|
positiveFeedback: false,
|
||||||
|
|
|
@ -8,7 +8,7 @@ privacyOptions = { // true means exposed
|
||||||
postCount: true,
|
postCount: true,
|
||||||
slug: true,
|
slug: true,
|
||||||
username: true,
|
username: true,
|
||||||
'profile.name': true,
|
'profile.username': true,
|
||||||
'profile.notifications': true,
|
'profile.notifications': true,
|
||||||
'profile.bio': true,
|
'profile.bio': true,
|
||||||
'profile.github': true,
|
'profile.github': true,
|
||||||
|
@ -24,14 +24,14 @@ privacyOptions = { // true means exposed
|
||||||
'votes.upvotedComments': true,
|
'votes.upvotedComments': true,
|
||||||
'votes.upvotedPosts': true
|
'votes.upvotedPosts': true
|
||||||
};
|
};
|
||||||
|
|
||||||
// minimum required properties to display avatars
|
// minimum required properties to display avatars
|
||||||
avatarOptions = {
|
avatarOptions = {
|
||||||
_id: true,
|
_id: true,
|
||||||
email_hash: true,
|
email_hash: true,
|
||||||
slug: true,
|
slug: true,
|
||||||
username: true,
|
username: true,
|
||||||
'profile.name': true,
|
'profile.username': true,
|
||||||
'profile.github': true,
|
'profile.github': true,
|
||||||
'profile.twitter': true,
|
'profile.twitter': true,
|
||||||
'services.twitter.profile_image_url': true,
|
'services.twitter.profile_image_url': true,
|
||||||
|
|
|
@ -34,7 +34,7 @@ getUserName = function(user){
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
getDisplayName = function(user){
|
getDisplayName = function(user){
|
||||||
return (user.profile && user.profile.name) ? user.profile.name : getUserName(user);
|
return (user.profile && user.profile.username) ? user.profile.username : getUserName(user);
|
||||||
};
|
};
|
||||||
getDisplayNameById = function(userId){
|
getDisplayNameById = function(userId){
|
||||||
return getDisplayName(Meteor.users.findOne(userId));
|
return getDisplayName(Meteor.users.findOne(userId));
|
||||||
|
|
|
@ -120,6 +120,47 @@ var migrationsList = {
|
||||||
});
|
});
|
||||||
return i;
|
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 () {
|
updateUserProfiles: function () {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var allUsers = Meteor.users.find();
|
var allUsers = Meteor.users.find();
|
||||||
|
|
|
@ -27,8 +27,8 @@ Accounts.onCreateUser(function(options, user){
|
||||||
user.email_hash = getEmailHash(user);
|
user.email_hash = getEmailHash(user);
|
||||||
|
|
||||||
// set username on profile
|
// set username on profile
|
||||||
if (!user.profile.name)
|
if (!user.profile.username)
|
||||||
user.profile.name = user.username;
|
user.profile.username = user.username;
|
||||||
|
|
||||||
// create slug from username
|
// create slug from username
|
||||||
user.slug = slugify(getUserName(user));
|
user.slug = slugify(getUserName(user));
|
||||||
|
|
Loading…
Add table
Reference in a new issue