Skip to content

Commit

Permalink
Change registration to return 404 (#152)
Browse files Browse the repository at this point in the history
Instead of default data, return 404
  • Loading branch information
Timothy-Gonzalez authored Jan 18, 2024
1 parent 7585ad1 commit bb3ef83
Showing 1 changed file with 7 additions and 25 deletions.
32 changes: 7 additions & 25 deletions src/services/registration/registration-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Models from "../../database/models.js";
import { RegistrationApplication } from "../../database/registration-db.js";
import { AdmissionDecision, DecisionResponse, DecisionStatus } from "../../database/admission-db.js";

import { Degree, Gender } from "./registration-models.js";
import { RegistrationFormat, isValidRegistrationFormat } from "./registration-formats.js";

import { hasElevatedPerms } from "../auth/auth-lib.js";
Expand Down Expand Up @@ -72,34 +71,17 @@ const registrationRouter: Router = Router();
* "hackOutreach": ["Instagram"]
* }
*/
registrationRouter.get("/", strongJwtVerification, async (_: Request, res: Response) => {
const defaultResponse = {
userId: "",
isProApplicant: false,
considerForGeneral: true,
preferredName: "",
legalName: "",
emailAddress: "",
gender: Gender.OTHER,
race: [],
requestedTravelReimbursement: false,
location: "",
degree: Degree.OTHER,
university: "",
gradYear: 0,
hackInterest: [],
hackOutreach: [],
dietaryRestrictions: [],
hackEssay1: "",
hackEssay2: "",
optionalEssay: "",
proEssay: "",
};
registrationRouter.get("/", strongJwtVerification, async (_: Request, res: Response, next: NextFunction) => {
const payload: JwtPayload = res.locals.payload;
const registrationData: RegistrationApplication | null = await Models.RegistrationApplications.findOne({
userId: payload.id,
});
return res.status(StatusCode.SuccessOK).send(registrationData ?? defaultResponse);

if (!registrationData) {
return next(new RouterError(StatusCode.ClientErrorNotFound, "NotFound"));
}

return res.status(StatusCode.SuccessOK).send(registrationData);
});

/**
Expand Down

0 comments on commit bb3ef83

Please sign in to comment.