Skip to content

Commit

Permalink
added endpoint to get unverified users
Browse files Browse the repository at this point in the history
  • Loading branch information
pm3512 committed Jan 26, 2024
1 parent dad0e50 commit 401f6e7
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 5 deletions.
46 changes: 41 additions & 5 deletions src/controllers/UsersController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ export const admitUser = async (req: Request, res: Response): Promise<void> => {
});

await user.setStatus(Status.ADMITTED);
await sendStatusUpdateEmail(user.email, profile?.firstName ?? "hacker", true);
await sendStatusUpdateEmail(
user.email,
profile?.firstName ?? "hacker",
true
);
res.status(200).send();
} catch (err) {
res.status(500).json(err);
Expand All @@ -152,7 +156,11 @@ export const admitAllCMU = async (
user: user._id,
event: tartanhacks._id,
});
await sendStatusUpdateEmail(user.email, profile?.firstName ?? "hacker", true);
await sendStatusUpdateEmail(
user.email,
profile?.firstName ?? "hacker",
true
);
};
promises.push(promise());
}
Expand Down Expand Up @@ -190,7 +198,11 @@ export const admitAllUsers = async (
user: user._id,
event: tartanhacks._id,
});
await sendStatusUpdateEmail(user.email, profile?.firstName ?? "hacker", true);
await sendStatusUpdateEmail(
user.email,
profile?.firstName ?? "hacker",
true
);
};
promises.push(promise());
}
Expand Down Expand Up @@ -228,7 +240,11 @@ export const rejectAllUsers = async (
user: user._id,
event: tartanhacks._id,
});
await sendStatusUpdateEmail(user.email, profile?.firstName ?? "hacker", false);
await sendStatusUpdateEmail(
user.email,
profile?.firstName ?? "hacker",
false
);
};
promises.push(promise);
}
Expand Down Expand Up @@ -262,7 +278,11 @@ export const rejectUser = async (
user: user._id,
});
await user.setStatus(Status.REJECTED);
await sendStatusUpdateEmail(user.email, profile?.firstName ?? "hacker", false);
await sendStatusUpdateEmail(
user.email,
profile?.firstName ?? "hacker",
false
);
res.status(200).send();
} catch (err) {
res.status(500).json(err);
Expand Down Expand Up @@ -303,6 +323,22 @@ export async function getVerifiedUserEmails(
}
}

export async function getUnverifiedUserEmails(
req: Request,
res: Response
): Promise<void> {
try {
const users = await User.find({
status: Status.UNVERIFIED,
});
const emails = users.map((user) => user.email);
const emailString = emails.join(", ");
res.status(200).send(emailString);
} catch (err) {
res.status(500).json(err);
}
}

export async function getAppliedUserEmails(
req: Request,
res: Response
Expand Down
24 changes: 24 additions & 0 deletions src/routes/participants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getConfirmedUserEmails,
getMentorEmails,
getParticipants,
getUnverifiedUserEmails,
getVerifiedUserEmails,
} from "../controllers/UsersController";
import { asyncCatch } from "../util/asyncCatch";
Expand Down Expand Up @@ -44,6 +45,29 @@ const router: Router = express.Router();
*/
router.get("/", isRecruiterOrAdmin, asyncCatch(getParticipants));

/**
* @swagger
* /participants/unverified:
* get:
* summary: Get emails of unverified participants
* security:
* - apiKeyAuth: []
* tags: [Participants Module]
* description: Retrieves list of emails of participants who have not verified their account. Access - Recruiter or Admin
* responses:
* 200:
* description: Success.
* 403:
* description: Forbidden.
* 500:
* description: Internal Server Error.
*/
router.get(
"/unverified",
isRecruiterOrAdmin,
asyncCatch(getUnverifiedUserEmails)
);

/**
* @swagger
* /participants/verified:
Expand Down

0 comments on commit 401f6e7

Please sign in to comment.