-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #372 from labzero/jeffrey/recaptcha
Implement reCAPTCHA
- Loading branch information
Showing
16 changed files
with
209 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ | |
"react-bootstrap": "^2.7.0", | ||
"react-dom": "npm:@preact/compat@*", | ||
"react-flip-toolkit": "^7.0.17", | ||
"react-google-recaptcha": "^3.1.0", | ||
"react-icons": "^4.7.1", | ||
"react-redux": "^8.0.5", | ||
"react-scroll": "^1.8.9", | ||
|
@@ -112,6 +113,7 @@ | |
"@types/react-autosuggest": "^10.1.6", | ||
"@types/react-dom": "^18.2.4", | ||
"@types/react-geosuggest": "^2.7.13", | ||
"@types/react-google-recaptcha": "^2.1.9", | ||
"@types/react-scroll": "^1.8.7", | ||
"@types/serialize-javascript": "^5.0.2", | ||
"@types/sinon": "^10.0.15", | ||
|
@@ -236,4 +238,4 @@ | |
"prepare": "husky install" | ||
}, | ||
"packageManager": "[email protected]" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,13 @@ describe("middlewares/invitation", () => { | |
let UserMock: SequelizeMockObject; | ||
let flashSpy: SinonSpy; | ||
|
||
let requestParams: Record<string, string>; | ||
|
||
beforeEach(() => { | ||
requestParams = { | ||
email: "[email protected]", | ||
"g-recaptcha-response": "12345", | ||
}; | ||
InvitationMock = dbMock.define("invitation", {}); | ||
RoleMock = dbMock.define("role", {}); | ||
UserMock = dbMock.define("user", {}); | ||
|
@@ -43,6 +49,13 @@ describe("middlewares/invitation", () => { | |
sendMail: sendMailSpy, | ||
}, | ||
}), | ||
"node-fetch": mockEsmodule({ | ||
default: async () => ({ | ||
json: async () => ({ | ||
success: true, | ||
}), | ||
}), | ||
}), | ||
...deps, | ||
}).default; | ||
|
||
|
@@ -83,7 +96,7 @@ describe("middlewares/invitation", () => { | |
|
||
request(app) | ||
.post("/") | ||
.send({ email: "[email protected]" }) | ||
.send(requestParams) | ||
.then((r) => { | ||
response = r; | ||
done(); | ||
|
@@ -118,7 +131,7 @@ describe("middlewares/invitation", () => { | |
|
||
request(app) | ||
.post("/") | ||
.send({ email: "[email protected]" }) | ||
.send(requestParams) | ||
.then((r) => { | ||
response = r; | ||
done(); | ||
|
@@ -151,7 +164,7 @@ describe("middlewares/invitation", () => { | |
}) | ||
); | ||
|
||
return request(app).post("/").send({ email: "[email protected]" }); | ||
return request(app).post("/").send(requestParams); | ||
}); | ||
|
||
it("sends confirmation", () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const submitRecaptchaForm = ( | ||
action: string, | ||
formData: { | ||
email: string; | ||
"g-recaptcha-response": string; | ||
} | ||
) => { | ||
const newForm = document.createElement("form"); | ||
newForm.method = "POST"; | ||
newForm.action = action; | ||
|
||
// Add all original form data | ||
Object.entries(formData).forEach(([key, value]) => { | ||
const input = document.createElement("input"); | ||
input.type = "hidden"; | ||
input.name = key; | ||
input.value = value; | ||
newForm.appendChild(input); | ||
}); | ||
|
||
document.body.appendChild(newForm); | ||
newForm.submit(); | ||
document.body.removeChild(newForm); | ||
}; | ||
|
||
export default submitRecaptchaForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.