diff --git a/assets/js/hubce.js b/assets/js/hubce.js new file mode 100644 index 000000000..d8b042693 --- /dev/null +++ b/assets/js/hubce.js @@ -0,0 +1,108 @@ +"use strict"; + +// requires newsletter.js +const VERIFY_EMAIL_URL = API_BASE_URL + '/connect/email/verify'; +const REFRESH_LICENSE_URL = API_BASE_URL + '/licenses/hub/refresh'; + +class HubCE { + + constructor(form, feedbackData, submitData, searchParams) { + this._form = form; + this._feedbackData = feedbackData; + this._submitData = submitData; + this._searchParams = searchParams; + this._submitData.oldLicense = searchParams.get('oldLicense'); + + // continue after email verified: + if (searchParams.get('verifiedEmail')) { + feedbackData.currentStep = 2; + feedbackData.success = true; + } + } + + submit() { + if (this._feedbackData.currentStep === 0) { + this.validateEmail(); + } else if (this._feedbackData.currentStep === 1) { + this.sendConfirmationEmail(); + } else if (this._feedbackData.currentStep === 2) { + this.getHubLicense(); + } + } + + validateEmail() { + if (!$(this._form)[0].checkValidity()) { + $(this._form).find(':input').addClass('show-invalid'); + this._feedbackData.errorMessage = 'Please fill in all required fields.'; + return; + } + this.onValidationSucceeded(); + } + + onValidationFailed(error) { + this._feedbackData.inProgress = false; + this._feedbackData.errorMessage = error; + } + + onValidationSucceeded() { + this._feedbackData.currentStep++; + this._feedbackData.inProgress = false; + this._feedbackData.errorMessage = ''; + } + + sendConfirmationEmail() { + if (!$(this._form)[0].checkValidity()) { + $(this._form).find(':input').addClass('show-invalid'); + this._feedbackData.errorMessage = 'Please fill in all required fields.'; + return; + } + + this._feedbackData.success = false; + this._feedbackData.inProgress = true; + this._feedbackData.errorMessage = ''; + $.ajax({ + url: VERIFY_EMAIL_URL, + type: 'POST', + data: { + email: this._submitData.email, + oldLicense: this._submitData.oldLicense, + verifyCaptcha: this._submitData.captcha, + verifyEmail: this._submitData.email, + verifyTarget: 'registerhubce' + } + }).done(_ => { + this.onRequestSucceeded(); + if (this._submitData.acceptNewsletter) { + subscribeToNewsletter(this._submitData.email, 7); // FIXME move to backend + } + }).fail(xhr => { + this.onRequestFailed(xhr.responseJSON?.message || 'Sending confirmation email failed.'); + }); + } + + getHubLicense() { + $.ajax({ + url: REFRESH_LICENSE_URL, + type: 'POST', + data: { + token: this._submitData.oldLicense + } + }).done(response => { + this._feedbackData.licenseText = response; + }).fail(xhr => { + this.onRequestFailed(xhr.responseJSON?.message || 'Fetching license failed.'); + }); + } + + onRequestFailed(error) { + this._feedbackData.inProgress = false; + this._feedbackData.errorMessage = error; + } + + onRequestSucceeded() { + this._feedbackData.currentStep++; + this._feedbackData.inProgress = false; + this._feedbackData.errorMessage = ''; + } + +} \ No newline at end of file diff --git a/content/hub-register.de.html b/content/hub-register.de.html new file mode 100644 index 000000000..4ae0011e9 --- /dev/null +++ b/content/hub-register.de.html @@ -0,0 +1,5 @@ +--- +title: "Cryptomator Hub: Registrieren" +url: "/de/hub/register" +type: "hub-register" +--- diff --git a/content/hub-register.en.html b/content/hub-register.en.html new file mode 100644 index 000000000..4e610fdb1 --- /dev/null +++ b/content/hub-register.en.html @@ -0,0 +1,5 @@ +--- +title: "Cryptomator Hub: Register" +url: "/hub/register" +type: "hub-register" +--- diff --git a/i18n/en.yaml b/i18n/en.yaml index ddbc6b247..86e5eecde 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -659,6 +659,35 @@ - id: hub_demo_contact_us_button translation: "Contact Us" +# Hub CE Registration +- id: hub_ce_registration_description + translation: "Register your Cryptomator Hub instance for a free Community Edition license." + +- id: hub_ce_registration_steps_title + translation: "Step of " +- id: hub_ce_registration_steps_next + translation: "Next" + +- id: hub_ce_registration_step_1_nav_title + translation: "Email Address" +- id: hub_ce_registration_step_1_title + translation: "What's your email address?" +- id: hub_ce_registration_step_1_email_placeholder + translation: "Email address" + +- id: hub_ce_registration_step_2_confirmation_nav_title + translation: "Confirmation" +- id: hub_ce_registration_step_2_confirmation_title + translation: "Please confirm your email address" +- id: hub_ce_registration_step_2_instructions + translation: "We are going to send a confirmation email to " + +- id: hub_ce_registration_step_3_license_nav_title + translation: "License Key" +- id: hub_ce_registration_step_3_license_title + translation: "Your Community Edition License Key" + + # Hub Managed - id: hub_managed_description translation: "Request access to a managed instance of Cryptomator Hub and get your team on board with client-side encryption for your cloud storage." diff --git a/layouts/hub-register/single.html b/layouts/hub-register/single.html new file mode 100644 index 000000000..192bf37d7 --- /dev/null +++ b/layouts/hub-register/single.html @@ -0,0 +1,188 @@ +{{ define "preloads" }} + {{ partial "altcha-css.html" . }} +{{ end }} +{{ define "main" }} +
+
+

{{ .Title }}

+

{{ i18n "hub_ce_registration_description" }}

+
+ + +
+
+ +
+ +
+ + + + + + + + + + + +
+
+
+{{ end }} +{{ define "script" }} + {{ if hugo.IsDevelopment }} + {{ $newsletterJs := resources.Get "js/newsletter.js" }} + + {{ $hubCeJs := resources.Get "js/hubce.js" }} + + {{ $altchaJs := resources.Get "js/altcha/altcha.js" }} + + {{ $altchaWorkerJs := resources.Get "js/altcha/worker.js" }} + + {{ else }} + {{ $newsletterJs := resources.Get "js/newsletter.js" | minify | fingerprint }} + + {{ $hubCeJs := resources.Get "js/hubce.js" | minify | fingerprint }} + + {{ $altchaJs := resources.Get "js/altcha/altcha.js" | minify | fingerprint }} + + {{ $altchaWorkerJs := resources.Get "js/altcha/worker.js" }} + + {{ end }} +{{ end }}