Skip to content

Commit 542ce96

Browse files
authored
fix: fix remove organization member (#417)
1 parent c3d0e2a commit 542ce96

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/actions/organization/members/list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async function organizationMembersList({ params }) {
3535
id: organizationId,
3636
type: 'organizationMembers',
3737
attributes: members.map(member => ({
38-
id: member.username,
38+
id: member.id,
3939
type: 'organizationMember',
4040
attributes: member,
4141
})),

src/actions/organization/members/remove.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@ async function removeMember({ params }) {
2626
const { audience } = config.organizations;
2727

2828
const userId = await getUserId.call(this, username);
29-
const memberKey = redisKey(userId, USERS_METADATA, audience);
30-
const userInOrganization = await redis.hget(memberKey, organizationId);
29+
const memberKey = redisKey(organizationId, ORGANIZATIONS_MEMBERS, userId);
30+
const memberMetadataKey = redisKey(userId, USERS_METADATA, audience);
31+
const userInOrganization = await redis.hget(memberMetadataKey, organizationId);
3132
if (!userInOrganization) {
3233
throw ErrorUserNotMember;
3334
}
3435

3536
const pipeline = redis.pipeline();
3637
pipeline.del(memberKey);
3738
pipeline.zrem(redisKey(organizationId, ORGANIZATIONS_MEMBERS), memberKey);
38-
pipeline.hdel(memberKey, organizationId);
39+
pipeline.hdel(memberMetadataKey, organizationId);
3940

4041
return pipeline.exec().then(handlePipeline);
4142
}

test/suites/organization/members/remove.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,16 @@ describe('#remove member from organization', function registerSuite() {
2828
username: this.userNames[0].email,
2929
};
3030

31-
return this.dispatch('users.organization.members.remove', opts)
31+
await this.dispatch('users.organization.members.remove', opts)
3232
.reflect()
3333
.then(inspectPromise(true));
34+
35+
return this.dispatch('users.organization.members.list', { organizationId: this.organization.id })
36+
.reflect()
37+
.then(inspectPromise(true))
38+
.then((response) => {
39+
assert.strictEqual(response.data.attributes.find(({ attributes }) => attributes.username === this.userNames[0].email), undefined);
40+
});
3441
});
3542

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

0 commit comments

Comments
 (0)