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

merge form fix #196

Merged
merged 8 commits into from
Dec 21, 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
10 changes: 5 additions & 5 deletions aws-lambdas/AppForm/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export const handler = async (event) => {
const formData = JSON.parse(event.body);

const refererError = RequestValidator.validateReferer(event.headers, process.env['ALLOWED_REFERER']);
if(!refererError) config = await configManager.loadConfig(FileType.Application);
const validationError = refererError === "" ? await RequestValidator.validateRequest(formData, FileType.Application, config.recaptchaV2VerifyUrl, config.recaptchaV2SecretKey) : 'Access forbidden';
if (validationError) {
return { statusCode: validationError === 'Access forbidden' ? 403 : 400, headers: HEADERS, body: validationError };
}
// if(!refererError) config = await configManager.loadConfig(FileType.Application);
// const validationError = refererError === "" ? await RequestValidator.validateRequest(formData, FileType.Application, config.recaptchaV2VerifyUrl, config.recaptchaV2SecretKey) : 'Access forbidden';
// if (validationError) {
// return { statusCode: validationError === 'Access forbidden' ? 403 : 400, headers: HEADERS, body: validationError };
// }

switch (formData.requestType) {
case RequestTypes.RequestThisAppToBeTested:
Expand Down
7 changes: 4 additions & 3 deletions aws-lambdas/utils/request-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ export default class RequestValidator {
static async validateRequest(data, fileType, recaptchaV2VerifyUrl, recaptchaV2SecretKey) {
let error = this.validateFormData(data, fileType);

if (error === "") {
error = await validateReCaptchaV2(recaptchaV2VerifyUrl, recaptchaV2SecretKey, data.token ?? "");
}
// PJC: disabled while recaptcha isn't working
// if (error === "") {
// error = await validateReCaptchaV2(recaptchaV2VerifyUrl, recaptchaV2SecretKey, data.token ?? "");
// }

return error;
}
Expand Down
22 changes: 12 additions & 10 deletions src/lib/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,22 @@ 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_APPLICATION_API_ENDPOINT}`, {
method: "POST",
body: JSON.stringify({
"name": data.get("name"),
"token": captchaVerificationToken,
// "token": captchaVerificationToken,
"token": "",
"publisher": data.get("publisher"),
"requestType": data.get("report"),
"appCategories": data.get("categories") ?? "",
Expand Down Expand Up @@ -91,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
5 changes: 0 additions & 5 deletions src/pages/[lang]/contributing/applications.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 @@ -131,14 +130,10 @@ const recaptcha_url = `https://www.google.com/recaptcha/api.js?hl=${locale}`;
<label class="block text-font-color text-lg mb-1" for="icon_url">{t('application_form.icon.description')}</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="icon_url" id="icon_url" placeholder={t('application_form.icon.instruction')} />
</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('application_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/applications.js"></script>
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>
8 changes: 6 additions & 2 deletions src/pages/en/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ Contributions for apps can be made directly to <a href="#how-to-contribute-via-g

Click the button 'App request form' and fill out the form with your App request. You can use this for requesting a new app to be tested and added, to tell us where we have something wrong for an app, or to submit your own new app data. We recommend you contribute via this form and not via the Github unless you have some technical experience. Scroll down to see more details on the defined schema and category definitions.

<a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="/en/contributing/applications">App request form</a>
<!-- <a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="/en/contributing/applications">App request form</a> -->

<a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="https://forms.office.com/r/JZ1ywk2FaJ">App request form</a>

### How to contribute via GitHub (apps)

Expand Down Expand Up @@ -87,7 +89,9 @@ Contributions can be made directly to <a href="#how-to-contribute-via-github-gam

Click the button 'Game request form' and fill out the below form with your game test details. We recommend you contribute via this form and not via the Github unless you have some technical experience. Scroll down to see more details on the defined schema and category definitions.

<a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="/en/contributing/games">Game request form</a>
<!-- <a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="/en/contributing/games">Game request form</a> -->

<a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="https://forms.office.com/pages/responsepage.aspx?id=v4j5cvGGr0GRqy180BHbR54qTg-u1FRHnQ3KYgdSD51UMDM4TFYzS1RUSUlHMjVRVkVUR0w5RlhJMC4u">Game request form</a>

### How to contribute via GitHub (games)

Expand Down
7 changes: 5 additions & 2 deletions src/pages/ja/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ description: このサイトに貢献する方法
### アプリリクエストフォームで貢献する方法
「アプリリクエストフォーム」ボタンをクリックして、アプリリクエストのフォームに入力してください。このフォームを使用して、テストと追加が必要な新しいアプリのリクエストを行ったり、アプリの誤りを知らせたり、新しいアプリデータを提出することができます。技術的な経験がない場合は、Githubではなくこのフォームから貢献することをお勧めします。定義されたスキーマとカテゴリの詳細については、下にスクロールしてください。

<a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="/ja/contributing/applications">アプリリクエストフォーム</a>
<!-- <a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="/ja/contributing/applications">アプリリクエストフォーム</a> -->

<a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="https://forms.office.com/r/JZ1ywk2FaJ">アプリリクエストフォーム</a>

### GitHubを使用して貢献する方法(アプリ)

Expand Down Expand Up @@ -85,8 +87,9 @@ description: このサイトに貢献する方法
### ゲームリクエストフォームで貢献する方法
「ゲームリクエストフォーム」ボタンをクリックして、以下のフォームにゲームテストの詳細を入力してください。技術的な経験がない場合は、Githubではなくこのフォームから貢献することをお勧めします。定義されたスキーマとカテゴリの詳細については、下にスクロールしてください。

<a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="/ja/contributing/games">ゲームリクエストフォーム</a>
<!-- <a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="/ja/contributing/games">ゲームリクエストフォーム</a> -->

<a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="https://forms.office.com/pages/responsepage.aspx?id=v4j5cvGGr0GRqy180BHbR54qTg-u1FRHnQ3KYgdSD51UMDM4TFYzS1RUSUlHMjVRVkVUR0w5RlhJMC4u">ゲームリクエストフォーム</a>
### GitHub を使用して貢献する方法 (ゲーム)

GitHub アカウントが必要です。まだアカウントをお持ちでない場合は、https://github.com にアクセスし、ページの右上隅にある **Sign up** をクリックし、指示に従って登録してください。
Expand Down
8 changes: 6 additions & 2 deletions src/pages/ko/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ description: 이 사이트에 기여하는 방법
### 앱 요청 양식을 통해 기여하는 방법
‘앱 요청 양식’ 버튼을 클릭하고 앱 요청 양식을 작성하세요. 이 양식을 통해 테스트 및 추가할 새로운 앱을 요청하거나, 앱에 대한 오류를 알리거나, 새로운 앱 데이터를 제출할 수 있습니다. 기술 경험이 없는 경우, Github 대신 이 양식을 통해 기여하는 것을 권장합니다. 정의된 스키마와 카테고리 정의에 대한 자세한 내용은 아래로 스크롤하여 확인하세요.

<a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="/ja/contributing/applications">앱 요청 양식</a>
<!-- <a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="/ja/contributing/applications">앱 요청 양식</a> -->

<a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="https://forms.office.com/r/JZ1ywk2FaJ">앱 요청 양식</a>

### GitHub를 통한 기여 방법 (애플리케이션)

Expand Down Expand Up @@ -85,7 +87,9 @@ GitHub 계정이 필요합니다. 계정이 없다면 https://github.com 으로
### 게임 요청 양식을 통해 기여하는 방법
‘게임 요청 양식’ 버튼을 클릭하고 아래의 게임 테스트 세부 정보를 입력하세요. 기술 경험이 없는 경우, Github 대신 이 양식을 통해 기여하는 것을 권장합니다. 정의된 스키마와 카테고리 정의에 대한 자세한 내용은 아래로 스크롤하여 확인하세요.

<a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="/ja/contributing/games">게임 요청 양식</a>
<!-- <a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="/ja/contributing/games">게임 요청 양식</a> -->

<a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="https://forms.office.com/pages/responsepage.aspx?id=v4j5cvGGr0GRqy180BHbR54qTg-u1FRHnQ3KYgdSD51UMDM4TFYzS1RUSUlHMjVRVkVUR0w5RlhJMC4u">게임 요청 양식</a>

### GitHub를 통한 기여 방법 (게임)

Expand Down
8 changes: 6 additions & 2 deletions src/pages/zh/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ description: 如何为此站点做出贡献
### 通过应用请求表单贡献
点击“应用请求表单”按钮,填写您的应用请求表单。您可以使用此表单请求测试并添加新应用、报告应用错误或提交新的应用数据。如果您没有技术经验,建议通过此表单而非Github进行贡献。向下滚动查看更多关于定义的架构和类别定义的详细信息。

<a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="/ja/contributing/applications">应用请求表单</a>
<!-- <a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="/ja/contributing/applications">应用请求表单</a> -->

<a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="https://forms.office.com/r/JZ1ywk2FaJ">应用请求表单</a>

### 通过 GitHub 进行贡献(应用程序)

Expand Down Expand Up @@ -85,7 +87,9 @@ description: 如何为此站点做出贡献
### 通过游戏请求表单贡献
点击“游戏请求表单”按钮,填写以下表单中的游戏测试详情。如果您没有技术经验,建议通过此表单而非Github进行贡献。向下滚动查看更多关于定义的架构和类别定义的详细信息。

<a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="/ja/contributing/games">游戏请求表单</a>
<!-- <a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="/ja/contributing/games">游戏请求表单</a> -->

<a class="border-white border-2 px-4 py-2 rounded-xl hover:bg-white hover:text-black no-underline" href="https://forms.office.com/pages/responsepage.aspx?id=v4j5cvGGr0GRqy180BHbR54qTg-u1FRHnQ3KYgdSD51UMDM4TFYzS1RUSUlHMjVRVkVUR0w5RlhJMC4u">游戏请求表单</a>

### 通过 GitHub 贡献(游戏)

Expand Down
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