Skip to content

Commit

Permalink
increment username if just exists
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanocudini committed Jan 10, 2019
1 parent 573bd4b commit 603c27d
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 13 deletions.
5 changes: 1 addition & 4 deletions packages/core/server/Accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ Accounts.onCreateUser(function(options, user) {
username = options.profile.username;
avatar = options.profile.picture;
lang = options.profile.languages[0];
/* emails = [{
address: user.services.openstreetmap.email,
verified: user.services.openstreetmap.verified_email
}];*/
emails = [];
}
//TODO else if(user.services.twitter) {
// source.service = 'twitter';
Expand Down
10 changes: 8 additions & 2 deletions packages/core/server/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ Meteor.methods({
$pull: {friends: blockUserId},
$addToSet: {usersBlocked: blockUserId}
});

Users.update(blockUserId, {
$pull: {
friends: this.userId,
Expand Down Expand Up @@ -139,11 +140,16 @@ Meteor.methods({
throw new Meteor.Error(500, i18n('error_novalid')+' '+i18n('error_validchars'));
*/
username = K.Util.sanitize.username(username);
if(username==='') {
throw new Meteor.Error(500, i18n('error_validchars'), username);
}

var user = Users.findOne({username: username}, {fields: {username:1}});

if(user && user._id !== this.userId)
throw new Meteor.Error(500, '<big>'+username+'</big> '+i18n('error_taken'));
if(user && user._id !== this.userId) {
var usernameInc = K.Util.sanitize.nthName(username);
throw new Meteor.Error(500, i18n('error_taken',username), usernameInc);
}

console.log('Profile: setUsername updated', this.userId, username);

Expand Down
2 changes: 1 addition & 1 deletion packages/i18n/i18n/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ i18n.map('de', {

error_novalid: "not valid",
error_validchars: "letters, numbers, '-' '.' '_' min 3 max 30 chars",
error_taken: "already been taken",
error_taken: "username <i>{$1}</i> already been taken",

btn_ok: "OK",
btn_cancel: "Abbrechen",
Expand Down
2 changes: 1 addition & 1 deletion packages/i18n/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ i18n.map('en', {

error_novalid: "not valid!",
error_validchars: "Use letters, numbers, '-' '.' '_' min 3 max 16 chars",
error_taken: "already been taken",
error_taken: "username <i>{$1}</i> already been taken",

btn_ok: "Ok",
btn_cancel: "Cancel",
Expand Down
2 changes: 1 addition & 1 deletion packages/i18n/i18n/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ i18n.map('es', {

error_novalid: "not valid",
error_validchars: "letters, numbers, '-' '.' '_' min 3 max 30 chars",
error_taken: "already been taken",
error_taken: "username <i>{$1}</i> already been taken",

btn_ok: "Ok",
btn_cancel: "Anular",
Expand Down
2 changes: 1 addition & 1 deletion packages/i18n/i18n/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ i18n.map('fr', {

error_novalid: "not valid",
error_validchars: "letters, numbers, '-' '.' '_' min 3 max 30 chars",
error_taken: "already been taken",
error_taken: "username <i>{$1}</i> already been taken",

btn_ok: "Ok",
btn_cancel: "Annuler",
Expand Down
2 changes: 1 addition & 1 deletion packages/i18n/i18n/it.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ i18n.map('it', {

error_novalid: "non valido",
error_validchars: "lettere, numberi, '-' '.' '_' min 3 max 30 caratteri",
error_taken: "gia stato preso",
error_taken: "username <i>{$1}</i> gia stato preso",

map_gps_title: "Tua posizione",
map_gps_error: "gps non disponibile",
Expand Down
2 changes: 1 addition & 1 deletion packages/i18n/i18n/sv.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ i18n.map('sv', {

error_novalid: "not valid",
error_validchars: "letters, numbers, '-' '.' '_' min 3 max 30 chars",
error_taken: "already been taken",
error_taken: "username <i>{$1}</i> already been taken",

btn_ok: "Ok",
btn_cancel: "Avbryt",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/client/views/panels/settings/bio.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Template.panelSettings_ui_bio.events({

if(err) {
mes$.html(err.reason)
input$.val( tmpl.data.username );
input$.val( err.details || tmpl.data.username );
}
else {
input$.val(sanitized);
Expand Down

0 comments on commit 603c27d

Please sign in to comment.