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