Skip to content

Add support mCaptcha as captcha provider #20458

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

Merged
merged 32 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d56af8e
Add config stuff
Jul 22, 2022
46be033
Load mCaptcha on register page
Jul 22, 2022
62ea258
Code-style
Jul 22, 2022
75d079d
Implement backend verification
Jul 22, 2022
614ad0b
Add copyright text
Jul 22, 2022
df5f337
Merge branch 'main' into add-mcaptcha
Jul 22, 2022
5015c38
Don't use hardcoded instance
Jul 23, 2022
890c583
Merge branch 'main' into add-mcaptcha
Jul 23, 2022
46fd68f
Merge branch 'main' into add-mcaptcha
Jul 23, 2022
3c84682
Merge branch 'main' into add-mcaptcha
Jul 23, 2022
d7c5033
Nit pick
Jul 23, 2022
747c47b
Merge branch 'main' into add-mcaptcha
Jul 23, 2022
773f07e
Merge branch 'main' into add-mcaptcha
6543 Jul 24, 2022
06c6c95
Apply suggestions from code review
6543 Jul 26, 2022
9ed76bb
Merge branch 'main' into add-mcaptcha
6543 Jul 26, 2022
668a701
Merge branch 'master' into add-mcaptcha
6543 Jul 26, 2022
4c52706
fix lint
6543 Jul 26, 2022
08790c5
Merge branch 'main' into add-mcaptcha
Jul 26, 2022
0789b33
Hack mobile CSS together
Jul 26, 2022
d29138b
Merge branch 'main' into add-mcaptcha
6543 Jul 27, 2022
c866103
Update mCaptcha-glue
Jul 28, 2022
9208741
Merge branch 'main' into add-mcaptcha
Jul 28, 2022
f4e417b
Use `<span>` instead of `<label>`
Jul 29, 2022
4ea9eb4
Merge branch 'main' into add-mcaptcha
Jul 29, 2022
eccc205
Merge branch 'main' into add-mcaptcha
Aug 1, 2022
db8a806
Merge branch 'main' into add-mcaptcha
Aug 2, 2022
5f219f2
Merge branch 'main' into add-mcaptcha
Aug 3, 2022
559cf0d
Fix incorrect formatting
Aug 3, 2022
24d059b
Merge branch 'main' into add-mcaptcha
Aug 9, 2022
540ae07
Fix borked package-lock.json
Aug 9, 2022
3b1c008
Merge branch 'main' into add-mcaptcha
6543 Aug 9, 2022
a1d9503
Merge branch 'main' into add-mcaptcha
6543 Aug 10, 2022
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
Prev Previous commit
Next Next commit
Don't use hardcoded instance
  • Loading branch information
Gusted committed Jul 23, 2022
commit 5015c38cdd5cc7aaef6073bcefc6542d6cd99aa7
2 changes: 1 addition & 1 deletion templates/user/auth/signup_inner.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<div class="inline field required df ac">
<label></label>
<div class="border-secondary" id="mcaptcha__widget-container" style="width: 304px; height: 78px"></div>
<div class="m-captcha" data-sitekey="{{ .McaptchaSitekey }}"></div>
<div class="m-captcha" data-sitekey="{{ .McaptchaSitekey }}" data-instance-url="{{ .McaptchaURL }}"></div>
</div>
{{end}}

Expand Down
2 changes: 1 addition & 1 deletion templates/user/auth/signup_openid_register.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
{{end}}
{{if and .EnableCaptcha (eq .CaptchaType "mcaptcha")}}
<div class="inline field required">
<div class="m-captcha" data-sitekey="{{ .McaptchaSitekey }}"></div>
<div class="m-captcha" data-sitekey="{{ .McaptchaSitekey }}" data-instance-url="{{ .McaptchaURL }}"></div>
</div>
{{end}}
<div class="inline field">
Expand Down
9 changes: 5 additions & 4 deletions web_src/js/features/mcaptcha.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
export async function initMcaptcha() {
const siteKeyEl = document.querySelector('.m-captcha');
if (!siteKeyEl) {
const mCaptchaEl = document.querySelector('.m-captcha');
if (!mCaptchaEl) {
return;
}

const {default: mCaptcha} = await import(/* webpackChunkName: "mcaptcha-vanilla-glue" */'@mcaptcha/vanilla-glue');
mCaptcha.INPUT_NAME = 'm-captcha-response';
const siteKey = siteKeyEl.getAttribute('data-sitekey');
const siteKey = mCaptchaEl.getAttribute('data-sitekey');
const instanceURL = mCaptchaEl.getAttribute('data-instance-url');

mCaptcha.default({
siteKey: {
instanceUrl: new URL('http://localhost:7000'),
instanceUrl: new URL(instanceURL),
key: siteKey,
}
});
Expand Down