Skip to content

Commit 5ac7ee3

Browse files
committed
Enhance Altcha integration and add it to all forms
1 parent 6c1601f commit 5ac7ee3

File tree

11 files changed

+34
-53
lines changed

11 files changed

+34
-53
lines changed

assets/js/cardpayments.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,15 @@ class OneTimePayment {
127127
this._status.success = false;
128128
this._status.errorMessage = error.message;
129129
this._status.inProgress = false;
130-
if (captcha) {
131-
this._status.captcha = '';
132-
captcha.reset();
133-
}
130+
this._status.captcha = null;
134131
}
135132

136133
onPaymentSucceeded() {
137134
console.info('Stripe payment succeeded!');
138135
this._status.success = true;
139136
this._status.errorMessage = '';
140137
this._status.inProgress = false;
141-
if (captcha) {
142-
this._status.captcha = '';
143-
captcha.reset();
144-
}
138+
this._status.captcha = null;
145139
}
146140

147141
}

hugo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,6 @@ block = true
125125
[[server.headers]]
126126
for = '/**'
127127
[server.headers.values]
128-
Content-Security-Policy = "default-src 'none'; script-src 'self' 'unsafe-eval' https://umami.skymatic.de/ https://plausible.skymatic.de/ https://community.cryptomator.org/ https://js.stripe.com/ https://*.paddle.com/; style-src 'self' 'unsafe-inline' https://*.paddle.com/; img-src 'self' data: https://static.cryptomator.org/ https://*.paddle.com/ https://paddle.s3.amazonaws.com/; connect-src 'self' https://api.cryptomator.org/ https://store.cryptomator.org/ https://windmill.skymatic.de/ https://umami.skymatic.de/ https://plausible.skymatic.de/ http://localhost:8787/; font-src 'self'; media-src https://static.cryptomator.org/; frame-src https://community.cryptomator.org/ https://js.stripe.com/ https://*.paddle.com/; base-uri 'self'; form-action 'self' https://www.paypal.com/ https://www.coinpayments.net/; frame-ancestors 'none';"
128+
Content-Security-Policy = "default-src 'none'; script-src 'self' 'unsafe-eval' https://umami.skymatic.de/ https://plausible.skymatic.de/ https://community.cryptomator.org/ https://js.stripe.com/ https://*.paddle.com/; style-src 'self' 'unsafe-inline' https://*.paddle.com/; img-src 'self' data: https://static.cryptomator.org/ https://*.paddle.com/ https://paddle.s3.amazonaws.com/; connect-src 'self' https://api.cryptomator.org/ https://store.cryptomator.org/ https://windmill.skymatic.de/ https://umami.skymatic.de/ https://plausible.skymatic.de/ http://localhost:8787/ http://localhost/; font-src 'self'; media-src https://static.cryptomator.org/; frame-src https://community.cryptomator.org/ https://js.stripe.com/ https://*.paddle.com/; base-uri 'self'; form-action 'self' https://www.paypal.com/ https://www.coinpayments.net/; frame-ancestors 'none';"
129129
Strict-Transport-Security = "max-age=31536000; includeSubDomains"
130130
X-Content-Type-Options = "nosniff"

i18n/en.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@
988988

989989
# Altcha
990990
- id: altcha_label
991-
translation: "I'm not a bot"
991+
translation: "I\\'m not a bot"
992992
- id: altcha_error
993993
translation: "Verification failed. Try again later."
994994
- id: altcha_expired

layouts/hub-billing/single.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{ define "main" }}
22
<div class="container pt-12 pb-24">
3-
<form x-data="{subscriptionData: {state: 'MISSING_PARAMS', captcha: null, hubId: null, returnUrl: null, session: null, customBilling: null, monthlyPrice: null, errorMessage: '', inProgress: false, restartModal: {open: false, nextPayment: null}, changeSeatsModal: {open: false, confirmation: false, immediatePayment: null}, token: null, details: null, quantity: 5, email: ''}, acceptTerms: false, hubSubscription: null}" x-init="hubSubscription = new HubSubscription($refs.form, subscriptionData, new URLSearchParams(location.search))" x-ref="form">
3+
<form x-data="{subscriptionData: {state: 'MISSING_PARAMS', captcha: null, hubId: null, returnUrl: null, session: null, customBilling: null, monthlyPrice: null, errorMessage: '', inProgress: false, restartModal: {open: false, nextPayment: null}, changeSeatsModal: {open: false, confirmation: false, immediatePayment: null}, token: null, details: null, quantity: 5, email: ''}, acceptTerms: false, hubSubscription: null, captchaState: null}" x-init="hubSubscription = new HubSubscription($refs.form, subscriptionData, new URLSearchParams(location.search))" x-ref="form">
44
<template x-if="subscriptionData.state == 'MISSING_PARAMS'">
55
<div class="text-center max-w-xl mx-auto">
66
<h3 class="font-headline text-xl md:text-2xl leading-relaxed mb-4">
@@ -35,13 +35,11 @@ <h3 class="font-headline text-xl md:text-2xl leading-relaxed mb-4">
3535
<i class="fas fa-sign-in fa-fw"></i>
3636
{{ i18n "hub_billing_createsession_description" . }}
3737
</p>
38-
<div class="mb-2">
39-
{{ partial "captcha.html" (dict "alpineVariable" "subscriptionData.captcha") }}
40-
</div>
41-
<button x-show="subscriptionData.captcha" :disabled="subscriptionData.inProgress" @click.prevent="hubSubscription.createSession()" type="submit" class="btn btn-primary w-full md:w-64">
38+
<button x-show="subscriptionData.captcha" :disabled="subscriptionData.inProgress || captchaState == 'verifying'" @click.prevent="hubSubscription.createSession()" type="submit" class="btn btn-primary w-full md:w-64">
4239
<i :class="{'fa-paper-plane': !subscriptionData.inProgress, 'fa-spinner fa-spin': subscriptionData.inProgress}" class="fas fa-fw" aria-hidden="true"></i>
4340
{{ i18n "hub_billing_createsession_submit" . }}
4441
</button>
42+
{{ partial "captcha.html" (dict "alpineVariable" "subscriptionData.captcha" "captchaState" "captchaState") }}
4543
<p :class="{'hidden': !subscriptionData.errorMessage}" class="text-sm text-red-600 mt-2" x-text="subscriptionData.errorMessage"></p>
4644
</div>
4745
</template>

layouts/hub-demo/single.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{ define "main" }}
2-
<section x-data="{feedbackData: {success: false, inProgress: false, errorMessage: '', url: null, username: null, password: null}, submitData: {captcha: null, email: ''}, hubDemo: null}" x-init="hubDemo = new HubDemo($refs.form, feedbackData, submitData)" class="container py-12">
2+
<section x-data="{feedbackData: {success: false, inProgress: false, errorMessage: '', url: null, username: null, password: null}, submitData: {captcha: null, email: ''}, hubDemo: null, captchaState: null}" x-init="hubDemo = new HubDemo($refs.form, feedbackData, submitData)" class="container py-12">
33
<header class="mb-6">
44
<h1 class="font-h1 mb-8">{{ .Title }}</h1>
55
<p class="lead">{{ i18n "hub_demo_description" }}</p>
@@ -58,12 +58,10 @@ <h3 class="font-h3">
5858
<p class="font-p mb-4">
5959
{{ i18n "hub_demo_instruction" }}
6060
</p>
61-
<div class="mb-4">
62-
{{ partial "captcha.html" (dict "alpineVariable" "submitData.captcha") }}
63-
</div>
64-
<button x-show="submitData.captcha" :disabled="feedbackData.inProgress" @click.prevent="hubDemo.request()" type="submit" class="btn btn-primary w-full md:w-64" x-cloak>
61+
<button x-show="submitData.captcha" :disabled="feedbackData.inProgress || captchaState == 'verifying'" @click.prevent="hubDemo.request()" type="submit" class="btn btn-primary w-full md:w-64" x-cloak>
6562
<i :class="{'fa-paper-plane': !feedbackData.inProgress, 'fa-spinner fa-spin': feedbackData.inProgress}" class="fas fa-fw" aria-hidden="true"></i> {{ i18n "hub_demo_submit" }}
6663
</button>
64+
{{ partial "captcha.html" (dict "alpineVariable" "submitData.captcha" "captchaState" "captchaState") }}
6765
<p :class="{'hidden': !feedbackData.errorMessage}" class="text-sm text-red-600 mt-2" x-text="feedbackData.errorMessage"></p>
6866
</div>
6967
</form>

layouts/hub-managed/single.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{{ define "main" }}
2-
<section x-data="{steps: ['{{ i18n "hub_managed_step_1_nav_title" }}', '{{ i18n "hub_managed_step_2_nav_title" }}', '{{ i18n "hub_managed_step_3_nav_title" }}', '{{ i18n "hub_managed_step_4_nav_title" }}'], feedbackData: {currentStep: 0, success: false, inProgress: false, errorMessage: ''}, submitData: {captcha: null, email: '', team: '', subdomain: '', quantity: null, message: null, acceptNewsletter: false}, acceptTerms: false, lowQuantityModalIsOpen: false, hubManaged: null}" x-init="hubManaged = new HubManaged($refs.form, feedbackData, submitData); $watch('submitData.team', team => submitData.subdomain = teamToSubdomain(team))" class="container py-12">
2+
<section x-data="{steps: ['{{ i18n "hub_managed_step_1_nav_title" }}', '{{ i18n "hub_managed_step_2_nav_title" }}', '{{ i18n "hub_managed_step_3_nav_title" }}', '{{ i18n "hub_managed_step_4_nav_title" }}'], feedbackData: {currentStep: 0, success: false, inProgress: false, errorMessage: ''}, submitData: {captcha: null, email: '', team: '', subdomain: '', quantity: null, message: null, acceptNewsletter: false}, acceptTerms: false, lowQuantityModalIsOpen: false, hubManaged: null, captchaState: null}" x-init="hubManaged = new HubManaged($refs.form, feedbackData, submitData); $watch('submitData.team', team => submitData.subdomain = teamToSubdomain(team))" class="container py-12">
33
<header class="mb-6">
44
<h1 class="font-h1 mb-8">{{ .Title }}</h1>
55
<p class="lead">{{ i18n "hub_managed_description" }}</p>
66
</header>
77

8-
<form x-ref="form">
8+
<form x-ref="form" @submit.prevent="hubManaged.request()">
99
<section class="white-box">
1010
<div x-show="!feedbackData.success" class="md:min-h-110 px-4 py-5 md:p-6 md:grid md:grid-cols-3 md:gap-6">
1111
<header class="mb-8 md:col-span-1 md:mt-4">
@@ -187,15 +187,13 @@ <h2 class="font-h2 mb-6">
187187
<p class="font-p text-sm mb-2">
188188
{{ partial "checkbox.html" (dict "context" . "alpineVariable" "submitData.acceptNewsletter" "label" (i18n "accept_hub_newsletter_optional")) }}
189189
</p>
190-
<div class="mb-2">
191-
{{ partial "captcha.html" (dict "alpineVariable" "submitData.captcha") }}
192-
</div>
193190
<div class="mt-auto">
194191
<p :class="{'hidden': !feedbackData.errorMessage}" class="text-sm text-red-600 mb-2" x-text="feedbackData.errorMessage"></p>
195-
<button :disabled="feedbackData.inProgress || !acceptTerms" @click.prevent="hubManaged.request()" type="submit" class="btn btn-primary w-full md:w-64 plausible-event-name=hub-managed-form" data-umami-event="hub-managed-form" x-cloak>
192+
<button :disabled="feedbackData.inProgress || !acceptTerms || captchaState == 'verifying'" type="submit" class="btn btn-primary w-full md:w-64 plausible-event-name=hub-managed-form" data-umami-event="hub-managed-form" x-cloak>
196193
<i :class="{'fa-paper-plane': !feedbackData.inProgress, 'fa-spinner fa-spin': feedbackData.inProgress}" class="fas fa-fw" aria-hidden="true"></i>
197194
{{ i18n "hub_managed_step_4_submit" }}
198195
</button>
196+
{{ partial "captcha.html" (dict "alpineVariable" "submitData.captcha" "captchaState" "captchaState") }}
199197
</div>
200198
</div>
201199
</div>

layouts/partials/captcha.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
challengeurl="https://windmill.skymatic.de/api/w/store/jobs/run_wait_result/p/f/captcha/challenge?token=pT9U3KnkRF4SvuChora34xRdhezaG3Yz&payload=e30%3D"
33
hidelogo
44
hidefooter
5+
floating="auto"
6+
@statechange="{{ .captchaState }} = $event.detail.state; if ($event.detail.state === 'verified') { {{ .alpineVariable }} = $event.detail.payload }"
57
:strings="JSON.stringify({
68
label: '{{ i18n "altcha_label" }}',
79
error: '{{ i18n "altcha_error" }}',
@@ -10,5 +12,4 @@
1012
verifying: '{{ i18n "altcha_verifying" }}',
1113
waitAlert: '{{ i18n "altcha_waitAlert" }}'
1214
})"
13-
x-on:statechange="if ($event.detail.state === 'verified') { {{ .alpineVariable }} = $event.detail.payload }"
1415
></altcha-widget>

layouts/partials/donate-creditcard.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div x-data="{amount: 15, currency: 'EUR', frequency: 'once', oneTimePayment: null, oneTimePaymentStatus: {validCardNum: false, captcha: null, errorMessage: '', inProgress: false, success: false}, recurringPayment: new RecurringPayment(), acceptTerms: false}" x-init="oneTimePayment = new OneTimePayment(oneTimePaymentStatus)">
1+
<div x-data="{amount: 15, currency: 'EUR', frequency: 'once', oneTimePayment: null, oneTimePaymentStatus: {validCardNum: false, captcha: null, errorMessage: '', inProgress: false, success: false}, recurringPayment: new RecurringPayment(), acceptTerms: false, captchaState: null}" x-init="oneTimePayment = new OneTimePayment(oneTimePaymentStatus)">
22
<div class="flex flex-wrap md:flex-nowrap">
33
<div class="w-full mb-4 md:w-1/2 md:pr-3">
44
<label class="label-uppercase mb-2">{{ i18n "donate_creditcard_amount" }}</label>
@@ -29,7 +29,7 @@
2929
</div>
3030
</div>
3131

32-
<div x-show="frequency === 'once'">
32+
<form x-show="frequency === 'once'" @submit.prevent="oneTimePayment.charge(amount, currency)">
3333
<div class="mb-4">
3434
<label class="label-uppercase mb-2">{{ i18n "donate_creditcard_number" }}</label>
3535
<div> <!-- wrapper needed for stripe text field -->
@@ -42,21 +42,19 @@
4242

4343
<p class="font-p mb-4">{{ partial "checkbox.html" (dict "context" . "alpineVariable" "acceptTerms" "label" (i18n "accept_privacy" | safeHTML)) }}</p>
4444

45-
<div class="flex justify-center mb-4">
46-
{{ partial "captcha.html" (dict "alpineVariable" "oneTimePaymentStatus.captcha") }}
47-
</div>
48-
49-
<button x-show="oneTimePaymentStatus.captcha" :disabled="oneTimePaymentStatus.inProgress || !acceptTerms" @click="oneTimePayment.charge(amount, currency)" class="btn btn-primary w-full md:w-64 plausible-event-name=donate-creditcard-onetime-checkout" data-umami-event="donate-creditcard-onetime-checkout">
45+
<button :disabled="oneTimePaymentStatus.inProgress || !oneTimePaymentStatus.validCardNum || !acceptTerms || captchaState == 'verifying'" class="btn btn-primary w-full md:w-64 plausible-event-name=donate-creditcard-onetime-checkout" data-umami-event="donate-creditcard-onetime-checkout">
5046
<i class="fas fa-credit-card"></i>
5147
{{ i18n "donate_creditcard_once_paynow" }}
5248
<i class="fas fa-spinner fa-spin" x-show="oneTimePaymentStatus.inProgress" aria-hidden="true"></i>
5349
</button>
5450

51+
{{ partial "captcha.html" (dict "alpineVariable" "oneTimePaymentStatus.captcha" "captchaState" "captchaState") }}
52+
5553
<p class="text-sm text-red-600 mt-2" x-text="oneTimePaymentStatus.errorMessage"></p>
5654
</div>
5755

5856
<p class="text-lg text-center mt-8" x-show="oneTimePaymentStatus.success">{{ ":+1:" | emojify }} {{ i18n "donate_creditcard_once_success" }}</p>
59-
</div>
57+
</form>
6058

6159
<div x-show="frequency === 'recurring'" class="text-center">
6260
<p class="font-p mb-4">{{ i18n "donate_creditcard_recurring_instruction" | safeHTML }}</p>

layouts/partials/supporter-cert-contributor.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<div x-data="{feedbackData: {success: false, inProgress: false, errorMessage: ''}, submitData: {captcha: null, type: 'contributor', email: '', github_username: '', github_contribution_link: ''}, acceptTerms: false}">
2-
<form x-show="!feedbackData.success" x-ref="form">
1+
<div x-data="{feedbackData: {success: false, inProgress: false, errorMessage: ''}, submitData: {captcha: null, type: 'contributor', email: '', github_username: '', github_contribution_link: ''}, acceptTerms: false, captchaState: null}">
2+
<form x-show="!feedbackData.success" x-ref="form" @submit.prevent="new SupporterCertificate($refs.form, feedbackData, submitData).request()">
33
<div class="mb-4">
44
<label class="label-uppercase mb-2">{{ i18n "supporter_cert_contributor_github_username" }}</label>
55
<input x-model="submitData.github_username" x-ref="github_username" @blur="$refs.github_username.classList.add('show-invalid')" type="text" class="input-box w-full" pattern="^[A-Za-z\d](?:[A-Za-z\d]|-(?=[A-Za-z\d])){0,38}$" maxlength="39" placeholder="{{ i18n "supporter_cert_contributor_github_username_placeholder" }}" required/>
@@ -15,12 +15,10 @@
1515
<div class="text-center mt-8">
1616
<p class="font-p mb-4">{{ i18n "supporter_cert_contributor_instruction" . | safeHTML }}</p>
1717
<p class="font-p mb-4">{{ partial "checkbox.html" (dict "context" . "alpineVariable" "acceptTerms" "label" (i18n "accept_terms_and_privacy" | safeHTML)) }}</p>
18-
<div class="flex justify-center mb-4">
19-
{{ partial "captcha.html" (dict "alpineVariable" "submitData.captcha") }}
20-
</div>
21-
<button x-show="submitData.captcha" :disabled="feedbackData.inProgress || !acceptTerms" @click.prevent="new SupporterCertificate($refs.form, feedbackData, submitData).request()" type="submit" class="btn btn-primary w-full md:w-64 plausible-event-name=supporter-cert-contributor-form" data-umami-event="supporter-cert-contributor-submit" x-cloak>
18+
<button :disabled="feedbackData.inProgress || !acceptTerms || captchaState == 'verifying'" class="btn btn-primary w-full md:w-64 plausible-event-name=supporter-cert-contributor-form" data-umami-event="supporter-cert-contributor-submit" x-cloak>
2219
<i :class="{'fa-paper-plane': !feedbackData.inProgress, 'fa-spinner fa-spin': feedbackData.inProgress}" class="fas fa-fw" aria-hidden="true"></i> {{ i18n "supporter_cert_common_submit" }}
2320
</button>
21+
{{ partial "captcha.html" (dict "alpineVariable" "submitData.captcha" "captchaState" "captchaState") }}
2422
<p :class="{'hidden': !feedbackData.errorMessage}" class="text-sm text-red-600 mt-2" x-text="feedbackData.errorMessage"></p>
2523
</div>
2624
</form>

layouts/partials/supporter-cert-influencer.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<div x-data="{feedbackData: {success: false, inProgress: false, errorMessage: ''}, submitData: {captcha: null, type: 'influencer', email: '', reference: ''}, acceptTerms: false}">
2-
<form x-show="!feedbackData.success" x-ref="form">
1+
<div x-data="{feedbackData: {success: false, inProgress: false, errorMessage: ''}, submitData: {captcha: null, type: 'influencer', email: '', reference: ''}, acceptTerms: false, captchaState: null}">
2+
<form x-show="!feedbackData.success" x-ref="form" @submit.prevent="new SupporterCertificate($refs.form, feedbackData, submitData).request()">
33
<div class="mb-4">
44
<label class="label-uppercase mb-2">{{ i18n "supporter_cert_influencer_reference" }}</label>
55
<textarea x-model="submitData.reference" x-ref="reference" @blur="$refs.reference.classList.add('show-invalid')" type="url" class="input-box w-full" rows="5" maxlength="800" placeholder="{{ i18n "supporter_cert_influencer_reference_placeholder" }}" required></textarea>
@@ -11,12 +11,10 @@
1111
<div class="text-center mt-8">
1212
<p class="font-p mb-4">{{ i18n "supporter_cert_influencer_instruction" }}</p>
1313
<p class="font-p mb-4">{{ partial "checkbox.html" (dict "context" . "alpineVariable" "acceptTerms" "label" (i18n "accept_terms_and_privacy" | safeHTML)) }}</p>
14-
<div class="flex justify-center mb-4">
15-
{{ partial "captcha.html" (dict "alpineVariable" "submitData.captcha") }}
16-
</div>
17-
<button x-show="submitData.captcha" :disabled="feedbackData.inProgress || !acceptTerms" @click.prevent="new SupporterCertificate($refs.form, feedbackData, submitData).request()" type="submit" class="btn btn-primary w-full md:w-64 plausible-event-name=supporter-cert-influencer-form" data-umami-event="supporter-cert-influencer-form" x-cloak>
14+
<button :disabled="feedbackData.inProgress || !acceptTerms || captchaState == 'verifying'" type="submit" class="btn btn-primary w-full md:w-64 plausible-event-name=supporter-cert-influencer-form" data-umami-event="supporter-cert-influencer-form" x-cloak>
1815
<i :class="{'fa-paper-plane': !feedbackData.inProgress, 'fa-spinner fa-spin': feedbackData.inProgress}" class="fas fa-fw" aria-hidden="true"></i> {{ i18n "supporter_cert_common_submit" }}
1916
</button>
17+
{{ partial "captcha.html" (dict "alpineVariable" "submitData.captcha" "captchaState" "captchaState") }}
2018
<p :class="{'hidden': !feedbackData.errorMessage}" class="text-sm text-red-600 mt-2" x-text="feedbackData.errorMessage"></p>
2119
</div>
2220
</form>

0 commit comments

Comments
 (0)