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
5 changes: 4 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,8 @@
"AUTH0_URL": "",
"TOKEN_CACHE_TIME": "",
"whitelistedOriginsForUserIdAuth": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]",
"AUTH0_PROXY_SERVER_URL" : ""
"AUTH0_PROXY_SERVER_URL" : "",
"EMAIL_INVITE_FROM_NAME":"Topcoder Connect",
"EMAIL_INVITE_FROM_EMAIL":"noreply@connect.topcoder.com"

}
38 changes: 37 additions & 1 deletion local/mock-services/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const middlewares = jsonServer.defaults();
const authMiddleware = require('./authMiddleware');

const members = require('./services.json').members;
const roles = require('./services.json').roles;

server.use(middlewares);

Expand All @@ -29,7 +30,12 @@ server.get('/v3/members/_search', (req, res) => {
const ret = {};
const splitted = single.split(':');
// if the result can be parsed successfully
const parsed = jsprim.parseInteger(splitted[1], { allowTrailing: true, trimWhitespace: true });
let parsed = Error();
try {
parsed = jsprim.parseInteger(splitted[1], { allowTrailing: true, trimWhitespace: true });
} catch (e) {
// no-empty
}
if (parsed instanceof Error) {
ret[splitted[0]] = splitted[1];
} else {
Expand All @@ -38,6 +44,7 @@ server.get('/v3/members/_search', (req, res) => {
return ret;
});
const userIds = _.map(criteria, 'userId');
const handles = _.map(criteria, 'handle');
const cloned = _.cloneDeep(members);
const response = {
id: 'res1',
Expand All @@ -53,13 +60,42 @@ server.get('/v3/members/_search', (req, res) => {
found = _.pick(found, fields);
}
return found;
} else if (_.indexOf(handles, single.result.content.handle) > -1) {
let found = single.result.content;
if (fields.length > 0) {
found = _.pick(found, fields);
}
return found;
}
return null;
}).filter(_.identity);
response.result.metadata = { totalCount: response.result.content.length };
res.status(200).json(response);
});

// add additional search route for project members
server.get('/roles', (req, res) => {
const filter = _.isString(req.query.filter) ?
req.query.filter.replace('%2520', ' ').replace('%20', ' ').split('=') : [];
const cloned = _.cloneDeep(roles);
const response = {
id: 'res1',
result: {
success: true,
status: 200,
},
};
const role = filter ? _.find(cloned, (single) => {
if (single.userId === filter[1]) {
return single.roles;
}
return null;
}) : null;

response.result.content = role ? role.roles : [];
res.status(200).json(response);
});

server.use(router);

server.listen(PORT, () => {
Expand Down
8 changes: 8 additions & 0 deletions local/mock-services/services.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,5 +300,13 @@
},
"version": "v3"
}
],
"roles": [
{ "userId": "40051334", "roles": [ { "roleName": "Connect Manager" } ] },
{ "userId": "40051332", "roles": [ { "roleName": "Connect Copilot" } ] },
{ "userId": "40051333", "roles": [ { "roleName": "administrator" } ] },
{ "userId": "40051336", "roles": [ { "roleName": "Connect Admin" }, { "roleName": "Connect Copilot" } ] },
{ "userId": "40051331", "roles": [ ] },
{ "userId": "40051335", "roles": [ ] }
]
}
35 changes: 35 additions & 0 deletions migrations/20181201_create_project_member_invites.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
--
-- CREATE NEW TABLES:
-- project_member_invites
--

--
-- project_member_invites
--

CREATE TABLE project_member_invites (
id bigint NOT NULL,
"projectId" bigint,
"userId" bigint,
email character varying(255),
role character varying(255) NOT NULL,
status character varying(255) NOT NULL,
"createdAt" timestamp with time zone,
"updatedAt" timestamp with time zone,
"deletedAt" timestamp with time zone,
"createdBy" integer NOT NULL,
"updatedBy" integer NOT NULL,
"deletedBy" bigint
);

CREATE SEQUENCE project_member_invites_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;

ALTER SEQUENCE project_member_invites_id_seq OWNED BY project_member_invites.id;

ALTER TABLE ONLY project_member_invites
ADD CONSTRAINT "project_member_invites_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES projects(id) ON UPDATE CASCADE ON DELETE CASCADE;
Loading