Skip to content

Commit

Permalink
cleaned up indirection endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
divyack2 committed Sep 17, 2024
1 parent ff63161 commit d048119
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 49 deletions.
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const DeviceRedirects: Record<string, string> = {
dev: `${API_BASE}/auth/dev/`,
mobile: "reflectionsprojections://--/Login",
admin: "https://admin.reflectionsprojections.org/auth/",
// admin: "http://localhost:5173/auth/",
};

export const ses = new AWS.SES({
Expand Down
41 changes: 9 additions & 32 deletions src/services/attendee/attendee-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,34 +251,18 @@ attendeeRouter.get(
}
);

// Get attendee merch info via email
attendeeRouter.get(
"/email/:EMAIL",
"/emails",
RoleChecker([Role.Enum.STAFF, Role.Enum.ADMIN]),
async (req, res, next) => {
try {
const email = req.params.EMAIL;
const registrations = await Database.ATTENDEE.find();
const attendeeData = registrations.map((registration) => ({
email: registration.email,
userId: registration.userId

Check failure on line 262 in src/services/attendee/attendee-router.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
}));

const user = await Database.ATTENDEE.findOne({ email });

if (!user) {
return res
.status(StatusCodes.NOT_FOUND)
.json({ error: "UserNotFound" });
}

const merchInfo = {
attendeeName: user.name,
attendeePoints: user.points,
hasButton: user.hasRedeemedMerch!["Button"],
hasCap: user.hasRedeemedMerch!["Cap"],
hasTote: user.hasRedeemedMerch!["Tote"],
eligibleButton: user.isEligibleMerch!["Button"],
eligibleCap: user.isEligibleMerch!["Cap"],
eligibleTote: user.isEligibleMerch!["Tote"],
};

return res.status(StatusCodes.OK).json(merchInfo);
return res.status(StatusCodes.OK).json(attendeeData);
} catch (error) {
next(error);
}
Expand All @@ -294,15 +278,8 @@ attendeeRouter.post(
const userId = payload.userId;
const merchItem = req.params.ITEM;

let user;

// Check if userId or email is provided and query the database accordingly
if (userId) {
user = await Database.ATTENDEE.findOne({ userId });
} else if (req.body.email) {
const email = req.body.email; // TODO: use a validator here?
user = await Database.ATTENDEE.findOne({ email });
}
// Check if the user exists in the database
const user = await Database.ATTENDEE.findOne({ userId });

if (!user) {
return res
Expand Down
17 changes: 0 additions & 17 deletions src/services/registration/registration-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,6 @@ registrationRouter.post("/save", RoleChecker([]), async (req, res, next) => {
}
});

registrationRouter.get(
"/emails",
RoleChecker([Role.Enum.STAFF, Role.Enum.ADMIN]),
async (req, res, next) => {
try {
const registrations = await Database.REGISTRATION.find();
const attendeeEmails = registrations.map(
(registration) => registration.email
);

return res.status(StatusCodes.OK).json(attendeeEmails);
} catch (error) {
next(error);
}
}
);

registrationRouter.post("/submit", RoleChecker([]), async (req, res, next) => {
try {
const payload = res.locals.payload;
Expand Down

0 comments on commit d048119

Please sign in to comment.