Skip to content

Commit 9c6aa78

Browse files
Merge branch 'develop' into iss2261
2 parents 2fd45e7 + fccab02 commit 9c6aa78

File tree

4 files changed

+11
-23
lines changed

4 files changed

+11
-23
lines changed

controllers/awsAccess.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ export const addUserToAWSGroup = async (req, res) => {
2121
if (awsUserId === null){
2222
// We need to create the user in AWS before and then fetch its Id
2323
userCreationResponse = await createUser(userInfoData.user.username, userInfoData.user.email);
24+
25+
if (userCreationResponse.conflict){
26+
return res.status(400).json({
27+
error: `Username or Email is already being used, please use another email / username for creating account in AWS`
28+
})
29+
}
2430
awsUserId = userCreationResponse.UserId;
2531
}
2632

routes/discordactions.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,11 @@ const ROLES = require("../constants/roles");
3030
const { Services } = require("../constants/bot");
3131
const { verifyCronJob } = require("../middlewares/authorizeBot");
3232
const { authorizeAndAuthenticate } = require("../middlewares/authorizeUsersAndService");
33-
const { devFlagMiddleware } = require("../middlewares/devFlag");
3433
const router = express.Router();
3534

3635
router.post("/groups", authenticate, checkIsVerifiedDiscord, validateGroupRoleBody, createGroupRole);
3736
router.get("/groups", authenticate, checkIsVerifiedDiscord, getAllGroupRoles);
38-
router.delete(
39-
"/groups/:groupId",
40-
authenticate,
41-
checkIsVerifiedDiscord,
42-
authorizeRoles([SUPERUSER]),
43-
devFlagMiddleware,
44-
deleteGroupRole
45-
);
37+
router.delete("/groups/:groupId", authenticate, checkIsVerifiedDiscord, authorizeRoles([SUPERUSER]), deleteGroupRole);
4638
router.post("/roles", authenticate, checkIsVerifiedDiscord, validateMemberRoleBody, addGroupRoleToMember);
4739
router.get("/invite", authenticate, getUserDiscordInvite);
4840
router.post("/invite", authenticate, checkCanGenerateDiscordLink, generateInviteForUser);

test/integration/discordactions.test.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,18 +233,6 @@ describe("Discord actions", function () {
233233
await cleanDb();
234234
});
235235

236-
it("should return 404 when not in dev mode", function (done) {
237-
chai
238-
.request(app)
239-
.delete(`/discord-actions/groups/${groupId}`)
240-
.set("cookie", `${cookieName}=${superUserAuthToken}`)
241-
.end((err, res) => {
242-
expect(res).to.have.status(404);
243-
expect(res.body.error).to.equal("Not Found");
244-
done(err);
245-
});
246-
});
247-
248236
it("should return 404 if group role not found", function (done) {
249237
sinon.stub(discordRolesModel, "isGroupRoleExists").resolves({
250238
roleExists: false,

utils/awsFunctions.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ import {
6767
const command = new CreateUserCommand(params);
6868
return (await client.send(command));
6969
} catch (error) {
70-
console.error(`The error from create user ${error}`);
70+
if (error.__type === 'ConflictException'){
71+
return { conflict: true };
72+
}
73+
7174
throw new Error(`Failed to create user: ${error instanceof Error ? error.message : String(error)}`);
7275
}
7376
};
@@ -93,7 +96,6 @@ export const addUserToGroup = async (groupId: string, awsUserId: string): Promis
9396
const command = new CreateGroupMembershipCommand(params);
9497
return (await client.send(command));
9598
} catch (error) {
96-
console.error("Error adding user to group:", error);
9799
if (error.__type === 'ConflictException'){
98100
return { conflict: true };
99101
}

0 commit comments

Comments
 (0)