fix(altcha): update attribute from challengeurl to challenge in Altcha component and home template
This commit is contained in:
@@ -12,13 +12,11 @@ interface AltchaProps {
|
||||
}
|
||||
|
||||
// altcha-widget یک custom element است؛ به JSX معرفی میشود (React 19: namespace زیر React.JSX).
|
||||
// همهی attributeها با setAttribute ست میشوند، نه JSX prop.
|
||||
declare module 'react' {
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
'altcha-widget': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
||||
challengeurl?: string;
|
||||
strings?: string;
|
||||
};
|
||||
'altcha-widget': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,9 +39,8 @@ export default function Altcha({ onVerified, challengeUrl = '/api/v1/altcha/chal
|
||||
return () => { alive = false; };
|
||||
}, [onVerified]);
|
||||
|
||||
// config (challengeurl/strings/auto) را با setAttribute ست میکنیم، نه JSX prop —
|
||||
// React ممکن است پراپ custom element را بهصورت property ست کند و widget آن را
|
||||
// نخواند؛ نتیجه challengeurl خالی و fetch صفحهی جاری (HTML) بهجای JSON بود.
|
||||
// config (challenge/language/auto) را با setAttribute ست میکنیم، نه JSX prop —
|
||||
// React ممکن است پراپ custom element را بهصورت property ست کند و widget آن را نخواند.
|
||||
useEffect(() => {
|
||||
if (enabled !== true) return;
|
||||
const el = ref.current;
|
||||
@@ -56,7 +53,9 @@ export default function Altcha({ onVerified, challengeUrl = '/api/v1/altcha/chal
|
||||
}
|
||||
};
|
||||
|
||||
el.setAttribute('challengeurl', challengeUrl);
|
||||
// widget v3 نام attribute را از challengeurl به challenge تغییر داده (docs v2)؛
|
||||
// challengeurl را observe نمیکند و بدون URL، صفحهی جاری (HTML) fetch میشد.
|
||||
el.setAttribute('challenge', challengeUrl);
|
||||
el.setAttribute('language', 'fa');
|
||||
el.setAttribute('auto', 'onload');
|
||||
el.addEventListener('statechange', onStateChange);
|
||||
|
||||
@@ -559,7 +559,8 @@
|
||||
|
||||
{% if altcha_enabled %}
|
||||
<!-- ALTCHA captcha — proof-of-work در پسزمینه (بدون تعامل کاربر) -->
|
||||
<altcha-widget id="regAltcha" challengeurl="/api/v1/altcha/challenge" auto="onload" language="fa" style="display:block;margin-top:16px"></altcha-widget>
|
||||
{# widget v3: attribute «challenge» (نه challengeurl قدیمی) #}
|
||||
<altcha-widget id="regAltcha" challenge="/api/v1/altcha/challenge" auto="onload" language="fa" style="display:block;margin-top:16px"></altcha-widget>
|
||||
{% endif %}
|
||||
|
||||
<!-- Error / Success -->
|
||||
|
||||
Reference in New Issue
Block a user