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
17 changes: 0 additions & 17 deletions schemas/deactivate.json

This file was deleted.

139 changes: 0 additions & 139 deletions src/actions/deactivate.js

This file was deleted.

20 changes: 12 additions & 8 deletions src/utils/organization/get-organization-members.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
const Promise = require('bluebird');
const mapValues = require('lodash/mapValues');
const { ORGANIZATIONS_MEMBERS } = require('../../constants');
const { ORGANIZATIONS_MEMBERS, USERS_DATA, USERS_BANNED_FLAG } = require('../../constants');
const redisKey = require('../key');

const JSONParse = (d) => JSON.parse(d);

async function getMemberData(organizationMemberId) {
const [, , userId] = organizationMemberId.split('!');
const organization = await this.redis.hgetall(organizationMemberId);
const banned = await this.redis.hget(redisKey(userId, USERS_DATA), USERS_BANNED_FLAG);

return mapValues({ ...organization, banned }, JSONParse);
}

async function getOrganizationMembers(organizationId) {
const { redis } = this;
const organizationMembersIds = await redis.zrange(redisKey(organizationId, ORGANIZATIONS_MEMBERS), 0, -1);
let organizationMembersJobs = [];
if (organizationMembersIds) {
organizationMembersJobs = organizationMembersIds.map((organizationMemberId) => redis.hgetall(organizationMemberId));
}
const organizationMembersIds = await redis.zrange(redisKey(organizationId, ORGANIZATIONS_MEMBERS), 0, -1) || [];
const organizationMembersJobs = organizationMembersIds.map(getMemberData, this);

const members = await Promise.all(organizationMembersJobs);
return members.map((member) => mapValues(member, JSONParse));
return Promise.all(organizationMembersJobs);
}

module.exports = getOrganizationMembers;
15 changes: 0 additions & 15 deletions test/suites/actions/activate.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ describe('#activate', function activateSuite() {
return true;
});
});

it('must deactivate account', async function test() {
const params = { username: email, audience: 'ok' };
await this.dispatch('users.deactivate', params);
});
});

describe('activate inactive user', function suite() {
Expand All @@ -73,16 +68,6 @@ describe('#activate', function activateSuite() {
});
});

it('must reject deactivation when account is already deactivated', async function test() {
const params = { username: email, audience: 'ok' };
await assert.rejects(this.dispatch('users.deactivate', params), (activation) => {
expect(activation.name).to.be.eq('HttpStatusError');
expect(activation.message).to.match(new RegExp(`Account ${email} was already deactivated`));
expect(activation.statusCode).to.be.eq(417);
return true;
});
});

it('must activate account when challenge token is correct and not expired', async function test() {
await this.dispatch('users.activate', { token: this.token });
});
Expand Down