Skip to content

Commit c8ee277

Browse files
Merge branch 'feature/register-hub-ce' into develop
2 parents 1fb5865 + ef3db24 commit c8ee277

File tree

5 files changed

+401
-0
lines changed

5 files changed

+401
-0
lines changed

assets/js/hubce.js

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
"use strict";
2+
3+
// requires newsletter.js
4+
const VERIFY_EMAIL_URL = API_BASE_URL + '/connect/email/verify';
5+
const REFRESH_LICENSE_URL = API_BASE_URL + '/licenses/hub/refresh';
6+
7+
class HubCE {
8+
9+
constructor(form, feedbackData, submitData, searchParams) {
10+
this._form = form;
11+
this._feedbackData = feedbackData;
12+
this._submitData = submitData;
13+
this._searchParams = searchParams;
14+
this._submitData.oldLicense = searchParams.get('oldLicense');
15+
this._submitData.returnUrl = searchParams.get('returnUrl');
16+
17+
// continue after email verified:
18+
if (searchParams.get('verifiedEmail')) {
19+
feedbackData.currentStep = 1;
20+
feedbackData.emailVerified = true;
21+
}
22+
}
23+
24+
submit() {
25+
if (this._feedbackData.currentStep === 0) {
26+
this.validateEmail();
27+
} else if (this._feedbackData.currentStep === 1) {
28+
this.sendConfirmationEmail();
29+
} else if (this._feedbackData.currentStep === 2) {
30+
this.getHubLicense();
31+
}
32+
}
33+
34+
validateEmail() {
35+
if (!$(this._form)[0].checkValidity()) {
36+
$(this._form).find(':input').addClass('show-invalid');
37+
this._feedbackData.errorMessage = 'Please fill in all required fields.';
38+
return;
39+
}
40+
this.onValidationSucceeded();
41+
}
42+
43+
onValidationFailed(error) {
44+
this._feedbackData.inProgress = false;
45+
this._feedbackData.errorMessage = error;
46+
}
47+
48+
onValidationSucceeded() {
49+
this._feedbackData.currentStep++;
50+
this._feedbackData.inProgress = false;
51+
this._feedbackData.errorMessage = '';
52+
}
53+
54+
sendConfirmationEmail() {
55+
if (!$(this._form)[0].checkValidity()) {
56+
$(this._form).find(':input').addClass('show-invalid');
57+
this._feedbackData.errorMessage = 'Please fill in all required fields.';
58+
return;
59+
}
60+
61+
this._feedbackData.success = false;
62+
this._feedbackData.inProgress = true;
63+
this._feedbackData.errorMessage = '';
64+
$.ajax({
65+
url: VERIFY_EMAIL_URL,
66+
type: 'POST',
67+
data: {
68+
email: this._submitData.email,
69+
oldLicense: this._submitData.oldLicense,
70+
returnUrl: this._submitData.returnUrl,
71+
verifyCaptcha: this._submitData.captcha,
72+
verifyEmail: this._submitData.email,
73+
verifyTarget: 'registerhubce'
74+
}
75+
}).done(_ => {
76+
this.onRequestSucceeded();
77+
if (this._submitData.acceptNewsletter) {
78+
subscribeToNewsletter(this._submitData.email, 7); // FIXME move to backend
79+
}
80+
}).fail(xhr => {
81+
this.onRequestFailed(xhr.responseJSON?.message || 'Sending confirmation email failed.');
82+
});
83+
}
84+
85+
getHubLicense() {
86+
this._feedbackData.inProgress = true;
87+
this._feedbackData.errorMessage = '';
88+
$.ajax({
89+
url: REFRESH_LICENSE_URL,
90+
type: 'POST',
91+
data: {
92+
token: this._submitData.oldLicense,
93+
captcha: this._submitData.captcha
94+
}
95+
}).done(response => {
96+
this._feedbackData.licenseText = response;
97+
this._feedbackData.inProgress = false;
98+
}).fail(xhr => {
99+
this.onRequestFailed(xhr.responseJSON?.message || 'Fetching license failed.');
100+
});
101+
}
102+
103+
onRequestFailed(error) {
104+
this._feedbackData.inProgress = false;
105+
this._feedbackData.errorMessage = error;
106+
}
107+
108+
onRequestSucceeded() {
109+
this._feedbackData.emailSent = true;
110+
this._feedbackData.inProgress = false;
111+
this._feedbackData.errorMessage = '';
112+
}
113+
114+
}

content/hub-register.de.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "Cryptomator Hub: Registrieren"
3+
url: "/de/hub/register"
4+
type: "hub-register"
5+
---

content/hub-register.en.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "Cryptomator Hub: Register"
3+
url: "/hub/register"
4+
type: "hub-register"
5+
---

i18n/en.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,45 @@
667667
- id: hub_demo_contact_us_button
668668
translation: "Contact Us"
669669

670+
# Hub CE Registration
671+
- id: hub_ce_registration_description
672+
translation: "Register your Cryptomator Hub instance for a free Community Edition license."
673+
674+
- id: hub_ce_registration_steps_title
675+
translation: "Step <span x-text=\"feedbackData.currentStep + 1\"></span> of <span x-text=\"steps.length\"></span>"
676+
- id: hub_ce_registration_steps_next
677+
translation: "Next"
678+
- id: hub_ce_registration_steps_continue
679+
translation: "Continue"
680+
681+
- id: hub_ce_registration_step_1_nav_title
682+
translation: "Email Address"
683+
- id: hub_ce_registration_step_1_title
684+
translation: "What's your email address?"
685+
- id: hub_ce_registration_step_1_email_placeholder
686+
translation: "Email address"
687+
688+
- id: hub_ce_registration_step_2_confirmation_nav_title
689+
translation: "Confirmation"
690+
- id: hub_ce_registration_step_2_confirmation_title
691+
translation: "Please confirm your email address"
692+
- id: hub_ce_registration_step_2_instructions
693+
translation: "We are going to send a confirmation email to <span x-text=\"submitData.email\"></span>"
694+
- id: hub_ce_registration_step_2_check_email
695+
translation: "Please check your e-mails."
696+
- id: hub_ce_registration_step_2_email_verified
697+
translation: "Your email has been verified successfully."
698+
699+
- id: hub_ce_registration_step_3_license_nav_title
700+
translation: "License Key"
701+
- id: hub_ce_registration_step_3_license_title
702+
translation: "Your Community Edition License Key"
703+
- id: hub_ce_registration_step_3_loading
704+
translation: "Loading license key..."
705+
- id: hub_ce_registration_step_3_success
706+
translation: "Your new license key:"
707+
708+
670709
# Hub Managed
671710
- id: hub_managed_description
672711
translation: "Request access to a managed instance of Cryptomator Hub and get your team on board with client-side encryption for your cloud storage."

0 commit comments

Comments
 (0)