Skip to content

Commit 5be4c9b

Browse files
committed
add retry button for failed token refresh and use x-if for captcha
Show a Retry button when the license token refresh fails, allowing the user to re-trigger the captcha and refresh flow. Switch the captcha container from x-show to x-if so the ALTCHA widget is fully destroyed and recreated on retry, guaranteeing a fresh challenge.
1 parent a9686bc commit 5be4c9b

4 files changed

Lines changed: 15 additions & 5 deletions

File tree

assets/js/hubsubscription.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ class HubSubscription {
518518
}
519519
}).fail(xhr => {
520520
this._subscriptionData.errorMessage = xhr.responseJSON?.message || 'Refreshing license failed.';
521+
this._subscriptionData.needsTokenRefresh = false;
521522
this._subscriptionData.inProgress = false;
522523
});
523524
}

i18n/de.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,8 @@
546546
translation: "Dies ist dein Lizenzschlüssel, der an deine Hub-ID gebunden ist. Drück auf den Button unten, um ihn automatisch auf deine Hub-Instanz zu übertragen."
547547
- id: hub_billing_manage_license_key_transfer_action
548548
translation: "Zum Hub übertragen"
549+
- id: hub_billing_manage_license_key_retry_action
550+
translation: "Erneut versuchen"
549551

550552
- id: hub_billing_manage_modal_charge_amount_description
551553
translation: "Rechnungsbetrag"

i18n/en.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,8 @@
546546
translation: "This is your license key that is bound to your Hub ID. Press the button below to transfer it to your Hub instance automatically."
547547
- id: hub_billing_manage_license_key_transfer_action
548548
translation: "Transfer to Hub"
549+
- id: hub_billing_manage_license_key_retry_action
550+
translation: "Retry"
549551

550552
- id: hub_billing_manage_modal_charge_amount_description
551553
translation: "Charge Amount"

layouts/hub-billing/single.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,18 @@ <h2 class="font-h2 mb-4 mt-12">
176176
{{ i18n "hub_billing_manage_license_key_instruction" . }}
177177
</p>
178178
<textarea x-model="subscriptionData.token" class="input-box w-full text-sm md:text-base leading-relaxed break-all" rows="6" readonly></textarea>
179-
<button :disabled="subscriptionData.inProgress || !subscriptionData.token" class="btn btn-primary text-center w-full md:w-64 mt-4" @click.prevent="hubSubscription.transferTokenToHub()">
179+
<button x-show="!subscriptionData.token" :disabled="subscriptionData.inProgress" @click.prevent="subscriptionData.errorMessage = ''; subscriptionData.needsTokenRefresh = true" class="btn btn-primary text-center w-full md:w-64 mt-4">
180+
{{ i18n "hub_billing_manage_license_key_retry_action" . }}
181+
</button>
182+
<button x-show="subscriptionData.token" :disabled="subscriptionData.inProgress" class="btn btn-primary text-center w-full md:w-64 mt-4" @click.prevent="hubSubscription.transferTokenToHub()">
180183
{{ i18n "hub_billing_manage_license_key_transfer_action" . }}
181184
</button>
182-
<div x-show="subscriptionData.needsTokenRefresh && !subscriptionData.inProgress" class="mt-4">
183-
{{ $challengeUrl := printf "%s/licenses/hub/challenge" .Site.Params.apiBaseUrl }}
184-
{{ partial "captcha.html" (dict "challengeUrl" $challengeUrl "captchaPayload" "subscriptionData.captcha" "captchaState" "captchaState" "ref" "refreshCaptcha" "auto" "onload" "onVerified" "hubSubscription.refreshToken()") }}
185-
</div>
185+
<template x-if="subscriptionData.needsTokenRefresh && !subscriptionData.inProgress">
186+
<div class="mt-4">
187+
{{ $challengeUrl := printf "%s/licenses/hub/challenge" .Site.Params.apiBaseUrl }}
188+
{{ partial "captcha.html" (dict "challengeUrl" $challengeUrl "captchaPayload" "subscriptionData.captcha" "captchaState" "captchaState" "ref" "refreshCaptcha" "auto" "onload" "onVerified" "hubSubscription.refreshToken()") }}
189+
</div>
190+
</template>
186191
<p x-show="subscriptionData.needsTokenRefresh && subscriptionData.inProgress" class="text-sm text-gray-600 mt-4">
187192
<i class="fa-solid fa-spinner fa-spin"></i>
188193
{{ i18n "hub_billing_loading_description" . }}

0 commit comments

Comments
 (0)