mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-26 11:57:34 -07:00
Refactor codes
This commit is contained in:
parent
2dd0094a95
commit
dd6f3579f0
3 changed files with 8 additions and 17 deletions
|
@ -40,20 +40,12 @@ export default Vue.extend({
|
|||
if (window.hcaptcha) { // loaded
|
||||
this.available = true;
|
||||
} else {
|
||||
const alreadyLoading = document.getElementById('hcaptcha');
|
||||
|
||||
if (alreadyLoading) { // loading
|
||||
alreadyLoading.addEventListener('load', () => this.available = true);
|
||||
|
||||
return;
|
||||
} // init
|
||||
|
||||
const script = document.createElement('script');
|
||||
script.addEventListener('load', () => this.available = true);
|
||||
script.async = true;
|
||||
script.id = 'hcaptcha';
|
||||
script.src = 'https://hcaptcha.com/1/api.js?render=explicit';
|
||||
document.head.appendChild(script);
|
||||
(document.getElementById('hcaptcha') || (x => document.head.appendChild(Object.assign(x, {
|
||||
async: true,
|
||||
id: 'hcaptcha',
|
||||
src: 'https://hcaptcha.com/1/api.js?render=explicit',
|
||||
})))(document.createElement('script')))
|
||||
.addEventListener('load', () => this.available = true);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -371,11 +371,10 @@ export default Vue.extend({
|
|||
}
|
||||
|
||||
if (recaptchaLoaded) { // loaded
|
||||
delete window.onRecaptchaLoad;
|
||||
renderRecaptchaPreview();
|
||||
} else { // init
|
||||
window.onRecaptchaLoad = () => {
|
||||
recaptchaLoaded = true;
|
||||
recaptchaLoaded = delete window.onRecaptchaLoad;
|
||||
renderRecaptchaPreview();
|
||||
};
|
||||
const script = document.createElement('script');
|
||||
|
|
|
@ -14,7 +14,7 @@ export default async (ctx: Koa.Context) => {
|
|||
// ただしテスト時はこの機構は障害となるため無効にする
|
||||
if (process.env.NODE_ENV !== 'test' && instance.enableHcaptcha && instance.hcaptchaSecretKey) {
|
||||
const success = await verify(instance.hcaptchaSecretKey, body['hcaptcha-response']).then(
|
||||
({ 'error-codes': x }) => !x || !x.length,
|
||||
({ success }) => success,
|
||||
() => false,
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue