Add Test to opt out of username being searchable

This commit is contained in:
Phillip Thelen
2018-11-27 13:20:26 +01:00
parent e9c86622c5
commit 0271d98b91
4 changed files with 9 additions and 3 deletions

View File

@@ -66,6 +66,9 @@
.checkbox .checkbox
input(type='checkbox', v-model='user.preferences.suppressModals.streak', @change='set("suppressModals", "streak")') input(type='checkbox', v-model='user.preferences.suppressModals.streak', @change='set("suppressModals", "streak")')
label {{ $t('suppressStreakModal') }} label {{ $t('suppressStreakModal') }}
.checkbox
input(type='checkbox', v-model='user.preferences.searchableUsername', @change='set("searchableUsername")')
label {{ $t('searchableUsernameSetting') }}
//- .checkbox //- .checkbox
//- label {{ $t('confirmScoreNotes') }} //- label {{ $t('confirmScoreNotes') }}
//- input(type='checkbox', v-model='user.preferences.tasks.confirmScoreNotes', @change='set({"preferences.tasks.confirmScoreNotes": user.preferences.tasks.confirmScoreNotes ? true: false})') //- input(type='checkbox', v-model='user.preferences.tasks.confirmScoreNotes', @change='set({"preferences.tasks.confirmScoreNotes": user.preferences.tasks.confirmScoreNotes ? true: false})')

View File

@@ -206,5 +206,7 @@
"usernameVerifiedConfirmation": "Your username, <%= username %>, is confirmed!", "usernameVerifiedConfirmation": "Your username, <%= username %>, is confirmed!",
"usernameNotVerified": "Please confirm your username.", "usernameNotVerified": "Please confirm your username.",
"changeUsernameDisclaimer": "We will be transitioning login names to unique, public usernames soon. This username will be used for invitations, @mentions in chat, and messaging.", "changeUsernameDisclaimer": "We will be transitioning login names to unique, public usernames soon. This username will be used for invitations, @mentions in chat, and messaging.",
"verifyUsernameVeteranPet": "One of these Veteran Pets will be waiting for you after you've finished confirming!" "verifyUsernameVeteranPet": "One of these Veteran Pets will be waiting for you after you've finished confirming!",
"searchableUsernameSetting": "Allow username to appear in searches",
"searchableUsernamePopover": "If enabled, other users can @mention and invite you easier."
} }

View File

@@ -16,13 +16,13 @@ api.getUsernameAutocompletes = {
let username = req.params.username.toLowerCase(); let username = req.params.username.toLowerCase();
if (username[0] === '@') username = username.slice(1, username.length); if (username[0] === '@') username = username.slice(1, username.length);
if (username.length < 2) { if (username.length < 1) {
res.respond(200, []); res.respond(200, []);
return; return;
} }
let members = await User let members = await User
.find({'auth.local.lowerCaseUsername': {$regex: `.*${username}.*`}, 'flags.verifiedUsername': true}) .find({'auth.local.lowerCaseUsername': {$regex: `.*${username}.*`}, 'flags.verifiedUsername': true, 'preferences.searchableUsername': {$ne: false}})
.select(['profile.name', 'contributor', 'auth.local.username']) .select(['profile.name', 'contributor', 'auth.local.username'])
.limit(20) .limit(20)
.exec(); .exec();

View File

@@ -460,6 +460,7 @@ let schema = new Schema({
reverseChatOrder: {$type: Boolean, default: false}, reverseChatOrder: {$type: Boolean, default: false},
background: String, background: String,
displayInviteToPartyWhenPartyIs1: {$type: Boolean, default: true}, displayInviteToPartyWhenPartyIs1: {$type: Boolean, default: true},
searchableUsername: {$type: Boolean, default: true},
webhooks: {$type: Schema.Types.Mixed, default: () => { webhooks: {$type: Schema.Types.Mixed, default: () => {
return {}; return {};
}}, }},