Skip to content

Commit

Permalink
Temporarily allow claim creation endpoint to be used for testing publ…
Browse files Browse the repository at this point in the history
…icly
  • Loading branch information
thesocialdev committed Jan 8, 2025
1 parent 059b0ea commit f7a2a22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions server/auth/session.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export class SessionGuard implements CanActivate {
"/api/health",
"/sign-up",
"/api/user/register",
"/api/claim", // Allow this route to be public temporarily for testing
].some((route) => request.url.startsWith(route));

const overridePublicRoutes =
Expand Down
9 changes: 7 additions & 2 deletions server/claim/claim.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,15 @@ export class ClaimController {
}
}

@IsPublic() // Allow this route to be public temporarily for testing
@ApiTags("claim")
@Post("api/claim/unattributed")
async createUnattributedClaim(@Body() createClaimDTO) {
try {
const claim = await this._createClaim(createClaimDTO);
const claim = await this._createClaim({
overrideCaptchaValidation: true,
...createClaimDTO,
});

return {
title: claim.title,
Expand Down Expand Up @@ -246,10 +250,11 @@ export class ClaimController {
}

private async _createClaim(createClaimDTO) {
const { overrideCaptchaValidation = false } = createClaimDTO;
const validateCaptcha = await this.captchaService.validate(
createClaimDTO.recaptcha
);
if (!validateCaptcha) {
if (!validateCaptcha && !overrideCaptchaValidation) {
throw new Error("Error validating captcha");
}
return this.claimService.create(createClaimDTO);
Expand Down

0 comments on commit f7a2a22

Please sign in to comment.