diff --git a/core/server/models/member.js b/core/server/models/member.js index 7fd50aec84..7595933cc1 100644 --- a/core/server/models/member.js +++ b/core/server/models/member.js @@ -155,8 +155,8 @@ const Member = ghostBookshelf.Model.extend({ }, searchQuery: function searchQuery(queryBuilder, query) { - queryBuilder.where('name', 'like', `%${query}%`); - queryBuilder.orWhere('email', 'like', `%${query}%`); + queryBuilder.where('members.name', 'like', `%${query}%`); + queryBuilder.orWhere('members.email', 'like', `%${query}%`); }, // TODO: hacky way to filter by members with an active subscription, diff --git a/test/regression/api/canary/admin/members_spec.js b/test/regression/api/canary/admin/members_spec.js index ecc85d8515..ea614e9f9f 100644 --- a/test/regression/api/canary/admin/members_spec.js +++ b/test/regression/api/canary/admin/members_spec.js @@ -70,6 +70,26 @@ describe('Members API', function () { }); }); + it('Can search for paid members', function () { + return request + .get(localUtils.API.getApiQuery('members/?search=egon&paid=true')) + .set('Origin', config.get('url')) + .expect('Content-Type', /json/) + .expect('Cache-Control', testUtils.cacheRules.private) + .expect(200) + .then((res) => { + should.not.exist(res.headers['x-cache-invalidate']); + const jsonResponse = res.body; + should.exist(jsonResponse); + should.exist(jsonResponse.members); + jsonResponse.members.should.have.length(1); + jsonResponse.members[0].email.should.equal('paid@test.com'); + localUtils.API.checkResponse(jsonResponse, 'members'); + localUtils.API.checkResponse(jsonResponse.members[0], 'member', 'stripe'); + localUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination'); + }); + }); + it('Add should fail when passing incorrect email_type query parameter', function () { const member = { name: 'test',