use or clause for display name and username search (#12820)

* use or clause for display name and username search

* update styling

* More style fix

* update comment and regex
This commit is contained in:
jbusa22
2020-11-30 14:05:58 -05:00
committed by GitHub
parent 3ce182d0dc
commit f077e40c4c

View File

@@ -322,9 +322,12 @@ function _getMembersForItem (type) {
} }
if (req.query.search) { if (req.query.search) {
// Creates a RegExp expression when querying for profile.name // Creates a RegExp expression when querying for profile.name and auth.local.username
const escapedSearch = escapeRegExp(req.query.search); const escapedSearch = escapeRegExp(req.query.search);
query['profile.name'] = { $regex: new RegExp(escapedSearch, 'i') }; query.$or = [
{ 'profile.name': { $regex: new RegExp(escapedSearch, 'i') } },
{ 'auth.local.username': { $regex: new RegExp(req.query.search, 'i') } },
];
} }
} else if (type === 'group-invites') { } else if (type === 'group-invites') {
if (group.type === 'guild') { // eslint-disable-line no-lonely-if if (group.type === 'guild') { // eslint-disable-line no-lonely-if