Skip to content

Commit dedf735

Browse files
committed
Merge hubToken and verificationToken into oldLicense
1 parent 4c53ee0 commit dedf735

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

assets/js/hubsubscription.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ class HubSubscription {
1313
this._form = form;
1414
this._subscriptionData = subscriptionData;
1515
let fragmentParams = new URLSearchParams(location.hash.substring(1));
16-
this._subscriptionData.hubToken = fragmentParams.get('oldLicense');
17-
if (this._subscriptionData.hubToken) {
16+
this._subscriptionData.oldLicense = fragmentParams.get('oldLicense');
17+
if (this._subscriptionData.oldLicense) {
1818
try {
19-
let base64 = this._subscriptionData.hubToken.split('.')[1].replace(/-/g, '+').replace(/_/g, '/');
19+
let base64 = this._subscriptionData.oldLicense.split('.')[1].replace(/-/g, '+').replace(/_/g, '/');
2020
this._subscriptionData.hubId = JSON.parse(atob(base64)).jti;
2121
} catch (e) {
2222
console.error('Failed to parse hub token:', e);
23-
this._subscriptionData.hubToken = null;
23+
this._subscriptionData.oldLicense = null;
2424
}
2525
}
2626
this._subscriptionData.hubId = this._subscriptionData.hubId ?? searchParams.get('hub_id');
@@ -68,7 +68,7 @@ class HubSubscription {
6868
}
6969

7070
onLoadSubscriptionSucceeded(data) {
71-
this._subscriptionData.verificationToken = data.token;
71+
this._subscriptionData.oldLicense = data.token;
7272
this._subscriptionData.details = data.subscription;
7373
if (data.subscription.quantity) {
7474
this._subscriptionData.quantity = data.subscription.quantity;
@@ -324,7 +324,7 @@ class HubSubscription {
324324

325325
onPostSucceeded(data) {
326326
this._subscriptionData.state = 'EXISTING_CUSTOMER';
327-
this._subscriptionData.verificationToken = data.token;
327+
this._subscriptionData.oldLicense = data.token;
328328
this._subscriptionData.details = data.subscription;
329329
this._subscriptionData.session = data.session;
330330
var searchParams = new URLSearchParams(window.location.search)
@@ -491,7 +491,7 @@ class HubSubscription {
491491
}
492492

493493
onPutSucceeded(data, shouldOpenReturnUrl) {
494-
this._subscriptionData.verificationToken = data.token;
494+
this._subscriptionData.oldLicense = data.token;
495495
this._subscriptionData.details = data.subscription;
496496
this._subscriptionData.errorMessage = '';
497497
this._subscriptionData.inProgress = false;
@@ -516,7 +516,7 @@ class HubSubscription {
516516
url: REFRESH_LICENSE_URL,
517517
type: 'POST',
518518
data: {
519-
token: this._subscriptionData.verificationToken,
519+
token: this._subscriptionData.oldLicense,
520520
captcha: this._subscriptionData.captcha
521521
}
522522
}).done(token => {

layouts/hub-billing/single.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{{ end }}
44
{{ define "main" }}
55
<div class="container pt-12 pb-24">
6-
<form x-data="{subscriptionData: {state: 'MISSING_PARAMS', captcha: null, hubId: null, returnUrl: null, session: null, hubToken: null, customBilling: null, billingInterval: 'yearly', savingsPercent: null, errorMessage: '', inProgress: false, restartModal: {open: false, nextPayment: null}, changeSeatsModal: {open: false, confirmation: false, immediatePayment: null}, token: null, details: null, quantity: 5, email: '', needsTokenRefresh: false, shouldTransferToHub: false}, acceptTerms: false, hubSubscription: null, captchaState: null}" x-init="hubSubscription = new HubSubscription($refs.form, subscriptionData, new URLSearchParams(location.search))" x-ref="form" @submit.prevent="hubSubscription.createSession(); $refs.captcha.reset()">
6+
<form x-data="{subscriptionData: {state: 'MISSING_PARAMS', captcha: null, hubId: null, returnUrl: null, session: null, oldLicense: null, customBilling: null, billingInterval: 'yearly', savingsPercent: null, errorMessage: '', inProgress: false, restartModal: {open: false, nextPayment: null}, changeSeatsModal: {open: false, confirmation: false, immediatePayment: null}, token: null, details: null, quantity: 5, email: '', needsTokenRefresh: false, shouldTransferToHub: false}, acceptTerms: false, hubSubscription: null, captchaState: null}" x-init="hubSubscription = new HubSubscription($refs.form, subscriptionData, new URLSearchParams(location.search))" x-ref="form" @submit.prevent="hubSubscription.createSession(); $refs.captcha.reset()">
77
<template x-if="subscriptionData.state == 'MISSING_PARAMS'">
88
<div class="text-center max-w-xl mx-auto">
99
<h3 class="font-headline text-xl md:text-2xl leading-relaxed mb-4">
@@ -314,8 +314,8 @@ <h3 class="font-headline text-xl md:text-2xl leading-relaxed mb-4" id="change-se
314314
<h1 class="font-h1 mb-8">{{ .Title }}</h1>
315315
<p class="lead">{{ i18n "hub_billing_checkout_description" . }}</p>
316316
</header>
317-
<div class="grid grid-cols-1 gap-4 mb-12" :class="subscriptionData.hubToken && !subscriptionData.customBilling?.managed ? 'md:grid-cols-3' : 'md:grid-cols-2'">
318-
<div x-show="subscriptionData.hubToken && !subscriptionData.customBilling?.managed" class="hidden md:block"></div>
317+
<div class="grid grid-cols-1 gap-4 mb-12" :class="subscriptionData.oldLicense && !subscriptionData.customBilling?.managed ? 'md:grid-cols-3' : 'md:grid-cols-2'">
318+
<div x-show="subscriptionData.oldLicense && !subscriptionData.customBilling?.managed" class="hidden md:block"></div>
319319
<div class="flex justify-center">
320320
<button class="w-1/2 py-2 border border-gray-300 rounded-l bg-gray-300 text-gray-700 hover:border-gray-400 hover:bg-gray-400 focus:bg-gray-400 focus:border-secondary" :class="{'border-gray-400 bg-gray-400 text-gray-800 font-medium': audience === 'business'}" @click.prevent="audience = 'business'">
321321
<i class="fa-building" :class="{'fas': audience === 'business', 'far': audience !== 'business'}"></i>
@@ -327,7 +327,7 @@ <h1 class="font-h1 mb-8">{{ .Title }}</h1>
327327
</button>
328328
</div>
329329
<div class="hidden md:block"></div>
330-
<div x-show="subscriptionData.hubToken && !subscriptionData.customBilling?.managed" class="flex flex-col white-box">
330+
<div x-show="subscriptionData.oldLicense && !subscriptionData.customBilling?.managed" class="flex flex-col white-box">
331331
<div class="p-4 border-b border-primary">
332332
<h2 class="inline-flex px-4 py-1 rounded-full text-sm font-medium tracking-wide uppercase bg-primary-l2 text-dark mb-4">
333333
{{ i18n "hub_billing_checkout_community_title" . }}
@@ -354,7 +354,7 @@ <h3 class="font-h3 mb-4 md:mb-0">
354354
{{ i18n "hub_billing_checkout_community_cta" . }}
355355
</p>
356356
</div>
357-
<a :href="`{{ "hub/register" | relLangURL }}#oldLicense=${encodeURIComponent(subscriptionData.hubToken)}&returnUrl=${encodeURIComponent(subscriptionData.returnUrl)}`" role="button" class="btn btn-primary w-full">
357+
<a :href="`{{ "hub/register" | relLangURL }}#oldLicense=${encodeURIComponent(subscriptionData.oldLicense)}&returnUrl=${encodeURIComponent(subscriptionData.returnUrl)}`" role="button" class="btn btn-primary w-full">
358358
<i class="fa-solid fa-user-plus"></i>
359359
{{ i18n "hub_billing_checkout_community_action" . }}
360360
</a>
@@ -442,7 +442,7 @@ <h2 class="inline-flex px-4 py-1 rounded-full text-sm font-medium tracking-wide
442442
</p>
443443
<p x-show="subscriptionData.customBilling?.managed" class="font-p mb-4">{{ partial "checkbox.html" (dict "context" . "alpineVariable" "acceptTerms" "label" (i18n "accept_hub_managed_terms_and_privacy" | safeHTML)) }}</p>
444444
<p x-show="!subscriptionData.customBilling?.managed" class="font-p mb-4">{{ partial "checkbox.html" (dict "context" . "alpineVariable" "acceptTerms" "label" (i18n "accept_terms_and_privacy" | safeHTML)) }}</p>
445-
<button :disabled="subscriptionData.inProgress || !acceptTerms" @click.prevent="hubSubscription.checkout('{{ .Site.Language.Lang }}')" type="button" class="btn btn-primary w-full" :class="!(subscriptionData.hubToken && !subscriptionData.customBilling?.managed) && 'lg:w-1/2'">
445+
<button :disabled="subscriptionData.inProgress || !acceptTerms" @click.prevent="hubSubscription.checkout('{{ .Site.Language.Lang }}')" type="button" class="btn btn-primary w-full" :class="!(subscriptionData.oldLicense && !subscriptionData.customBilling?.managed) && 'lg:w-1/2'">
446446
<i :class="{'fa-shopping-cart': !subscriptionData.inProgress, 'fa-check': !subscriptionData.inProgress, 'fa-spinner fa-spin': subscriptionData.inProgress}" class="fa-solid" aria-hidden="true"></i>
447447
{{ i18n "hub_billing_checkout_standard_submit" . }}
448448
</button>
@@ -477,7 +477,7 @@ <h3 class="font-h3 mb-4 md:mb-0">
477477
{{ i18n "hub_billing_checkout_enterprise_cta" . }}
478478
</p>
479479
</div>
480-
<a href="mailto:hub@cryptomator.org" role="button" class="btn btn-primary w-full" :class="!(subscriptionData.hubToken && !subscriptionData.customBilling?.managed) && 'lg:w-1/2'">
480+
<a href="mailto:hub@cryptomator.org" role="button" class="btn btn-primary w-full" :class="!(subscriptionData.oldLicense && !subscriptionData.customBilling?.managed) && 'lg:w-1/2'">
481481
<i class="fa-solid fa-envelope"></i>
482482
{{ i18n "hub_billing_checkout_enterprise_action" . }}
483483
</a>

0 commit comments

Comments
 (0)