Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/actions/organization/members/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function organizationMembersList({ params }) {
id: organizationId,
type: 'organizationMembers',
attributes: members.map(member => ({
id: member.username,
id: member.id,
type: 'organizationMember',
attributes: member,
})),
Expand Down
7 changes: 4 additions & 3 deletions src/actions/organization/members/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ async function removeMember({ params }) {
const { audience } = config.organizations;

const userId = await getUserId.call(this, username);
const memberKey = redisKey(userId, USERS_METADATA, audience);
const userInOrganization = await redis.hget(memberKey, organizationId);
const memberKey = redisKey(organizationId, ORGANIZATIONS_MEMBERS, userId);
const memberMetadataKey = redisKey(userId, USERS_METADATA, audience);
const userInOrganization = await redis.hget(memberMetadataKey, organizationId);
if (!userInOrganization) {
throw ErrorUserNotMember;
}

const pipeline = redis.pipeline();
pipeline.del(memberKey);
pipeline.zrem(redisKey(organizationId, ORGANIZATIONS_MEMBERS), memberKey);
pipeline.hdel(memberKey, organizationId);
pipeline.hdel(memberMetadataKey, organizationId);

return pipeline.exec().then(handlePipeline);
}
Expand Down
9 changes: 8 additions & 1 deletion test/suites/organization/members/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,16 @@ describe('#remove member from organization', function registerSuite() {
username: this.userNames[0].email,
};

return this.dispatch('users.organization.members.remove', opts)
await this.dispatch('users.organization.members.remove', opts)
.reflect()
.then(inspectPromise(true));

return this.dispatch('users.organization.members.list', { organizationId: this.organization.id })
.reflect()
.then(inspectPromise(true))
.then((response) => {
assert.strictEqual(response.data.attributes.find(({ attributes }) => attributes.username === this.userNames[0].email), undefined);
});
});

it('must return organization not found error', async function test() {
Expand Down