Skip to content

Commit

Permalink
feat: update captcha - fix #100 (#102)
Browse files Browse the repository at this point in the history
* feat: update captcha - fix #100

* feat: update captcha - fix #100
  • Loading branch information
pagoru authored Oct 4, 2024
1 parent 2f43fff commit 5767dfd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { useCallback, useEffect, useState } from "react";
import { CAPTCHA_ID, CAPTCHA_URL } from "shared/consts";

type Props = {
submittedAt: number;
onResolve: (sessionId: string) => void;
};

const CAPTCHA_ID = `hwoFA5ORzPAYkHyCNElRU0F3WXAD0ZN9`;

export const CaptchaComponent: React.FC<Props> = ({
submittedAt,
onResolve,
Expand All @@ -17,9 +16,9 @@ export const CaptchaComponent: React.FC<Props> = ({

const $refreshCaptcha = useCallback(
() =>
fetch(`https://captcha.openhotel.club/v1/captcha?id=${CAPTCHA_ID}`)
fetch(`${CAPTCHA_URL}/v1/captcha?id=${CAPTCHA_ID}`)
.then((data) => data.json())
.then(({ sessionId, image, question }) => {
.then(({ sessionId, image }) => {
setSessionId(sessionId);
setCaptchaImage(image);
}),
Expand All @@ -43,7 +42,7 @@ export const CaptchaComponent: React.FC<Props> = ({
const headers = new Headers();
headers.append("Content-Type", "application/json");

fetch("https://captcha.openhotel.club/v1/captcha/response", {
fetch(`${CAPTCHA_URL}/v1/captcha/response`, {
method: "POST",
headers,
body: JSON.stringify({
Expand Down
5 changes: 5 additions & 0 deletions app/client/src/shared/consts/captcha.consts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const CAPTCHA_URL = "https://captcha.openhotel.club";

//"http://localhost:1960"
//"r2T4jtjmwjkMREqmGgCyV618zLns5UUv"
export const CAPTCHA_ID = `hwoFA5ORzPAYkHyCNElRU0F3WXAD0ZN9`;
1 change: 1 addition & 0 deletions app/client/src/shared/consts/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./urls.consts";
export * from "./captcha.consts";
3 changes: 2 additions & 1 deletion app/server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
database
database-shm
database-wal
config.yml
config.yml
abc_config.yml

0 comments on commit 5767dfd

Please sign in to comment.