Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Fix issues with recaptcha #193

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ jobs:
GITHUB_BASE_BRANCH: ${{ vars.GH_BASE_BRANCH }}
GITHUB_OWNER: ${{ vars.GH_OWNER }}
GITHUB_REPO: ${{ vars.GH_REPO }}
RECAPTCHA_V2_VERIFY_URL: ${{ vars.PUBLIC_CAPTCHA_WEB_SITE_KEY }}
RECAPTCHA_V2_VERIFY_URL: ${{ vars.RECAPTCHA_V2_VERIFY_URL }}
RECAPTCHA_V2_SECRET_KEY: ${{ secrets.RECAPTCHA_V2_SECRET_KEY }}
PUBLIC_API_HOST: ${{ vars.PUBLIC_API_HOST }}
PUBLIC_APPLICATION_API_ENDPOINT: ${{ vars.PUBLIC_APPLICATION_API_ENDPOINT }}
PUBLIC_GAME_API_ENDPOINT: ${{ vars.PUBLIC_GAME_API_ENDPOINT }}
run: |
# Set up the environment variables
export NODE_OPTIONS=--experimental-wasm-modules
Expand Down
4 changes: 2 additions & 2 deletions src/lib/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ form.addEventListener("submit", (e) => {
// showErrorAlert(errorAlertId, errorAlertInnerElementId, false, "");
// }, 3000);
// } else
{
// {
var data = new FormData(form)
fetch(`${import.meta.env.PUBLIC_API_HOST}${import.meta.env.PUBLIC_APPLICATION_API_ENDPOINT}`, {
method: "POST",
Expand Down Expand Up @@ -93,7 +93,7 @@ form.addEventListener("submit", (e) => {
showErrorAlert(errorAlertId, errorAlertInnerElementId, false, '');
}, 3000);
})
};
// };
});

//######################################## Loader ########################################//
Expand Down
21 changes: 11 additions & 10 deletions src/lib/games.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@ form.addEventListener("submit", (e) => {
e.preventDefault();
pageLoading(true);

var captchaVerificationToken = grecaptcha.getResponse();
if (captchaVerificationToken.length == 0) {
showSuccessAlert(successAlertId, false);
showErrorAlert(errorAlertId, errorAlertInnerElementId, true, ErrorMessages.MISSING_CAPTCHA_ERROR);
setTimeout(() => {
showErrorAlert(errorAlertId, errorAlertInnerElementId, false, '');
}, 3000);
} else {
// var captchaVerificationToken = grecaptcha.getResponse();
// if (captchaVerificationToken.length == 0) {
// showSuccessAlert(successAlertId, false);
// showErrorAlert(errorAlertId, errorAlertInnerElementId, true, ErrorMessages.MISSING_CAPTCHA_ERROR);
// setTimeout(() => {
// showErrorAlert(errorAlertId, errorAlertInnerElementId, false, '');
// }, 3000);
// } else {
var data = new FormData(form);
fetch(`${import.meta.env.PUBLIC_API_HOST}${import.meta.env.PUBLIC_GAME_API_ENDPOINT}`, {
method: "POST",
body: JSON.stringify({
"name": data.get("name"),
"token": captchaVerificationToken,
// "token": captchaVerificationToken,
"token": "",
"publisher": data.get("publisher"),
"categories": data.get("categories") ?? "",
"compatibility": data.get("compatibility") ?? "",
Expand Down Expand Up @@ -65,7 +66,7 @@ form.addEventListener("submit", (e) => {
showErrorAlert(errorAlertId, errorAlertInnerElementId, false, '');
}, 3000);
})
}
// }
});

//######################################## Loader ########################################//
Expand Down
7 changes: 1 addition & 6 deletions src/pages/[lang]/contributing/games.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export function getStaticPaths() {
}

const locale = updateLanguage(Astro.url);
const recaptcha_url = `https://www.google.com/recaptcha/api.js?hl=${locale}`;
---

<BaseLayout
Expand Down Expand Up @@ -134,15 +133,11 @@ const recaptcha_url = `https://www.google.com/recaptcha/api.js?hl=${locale}`;
<label class="block text-font-color text-lg mb-1" for="gamertag">{t('game_form.your_name_gamertag')}</label>
<input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" type="text" name="gamertag" id="gamertag" />
</div>
<div class="mb-12">
<div class="g-recaptcha" data-sitekey=`${import.meta.env.PUBLIC_CAPTCHA_WEB_SITE_KEY}`></div>
</div>
<div class="mb-12">
<input type="submit" value={t('game_form.submit_button')} class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"></input>
</div>
</form>
</div>
</BaseLayout>

<script define:vars={{recaptcha_url}} src={recaptcha_url} async defer></script>
<script src="../../../lib/games.js"></script>
<script src="../../../lib/games.js"></script>
3 changes: 3 additions & 0 deletions sst.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export default {
customDomain: cd,
environment: {
IS_PUBLIC: "true",
PUBLIC_API_HOST: process.env.PUBLIC_API_HOST!,
PUBLIC_APPLICATION_API_ENDPOINT: process.env.PUBLIC_APPLICATION_API_ENDPOINT!,
PUBLIC_GAME_API_ENDPOINT: process.env.PUBLIC_GAME_API_ENDPOINT!,
},
cdk: {
distribution: {
Expand Down
Loading