/
RegisterArea.vue
1564 lines (1330 loc) · 52.4 KB
/
RegisterArea.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (C) 2021 Storj Labs, Inc.
// See LICENSE for copying information.
<template>
<div class="register-area" @keyup.enter="onCreateClick">
<div
class="register-area__container"
:class="{'professional-container': isProfessional}"
>
<div class="register-area__intro-area">
<div class="register-area__logo-wrapper">
<div v-if="!!viewConfig.partnerLogoTopUrl" class="register-area__logo-wrapper__container">
<a :href="viewConfig.partnerUrl">
<img
:src="viewConfig.partnerLogoTopUrl"
:srcset="viewConfig.partnerLogoTopUrl"
alt="partner logo"
class="register-area__logo-wrapper__logo logo"
>
</a>
</div>
<div v-if="viewConfig.partnerLogoTopUrl" class="logo-divider" />
<div class="register-area__logo-wrapper__container">
<LogoWithPartnerIcon v-if="viewConfig.partnerLogoTopUrl" class="logo-with-partner" @click="onLogoClick" />
<LogoIcon v-else class="logo-no-partner" @click="onLogoClick" />
</div>
</div>
<h1 class="register-area__intro-area__title">{{ viewConfig.title }}</h1>
<p v-if="viewConfig.description" class="register-area__intro-area__sub-title">{{ viewConfig.description }}</p>
<div class="register-area__intro-area__large-content">
<!-- eslint-disable-next-line vue/no-v-html -->
<div v-if="viewConfig.customHtmlDescription" class="register-area__intro-area__large-content__custom-html-container" v-html="viewConfig.customHtmlDescription" />
<div v-if="!!viewConfig.partnerLogoBottomUrl" class="register-area__logo-wrapper bottom">
<div class="register-area__logo-wrapper__container">
<img :src="viewConfig.partnerLogoBottomUrl" :srcset="viewConfig.partnerLogoBottomUrl" alt="partner logo" class="register-area__logo-wrapper__logo wide">
</div>
</div>
<RegisterGlobe
v-if="!viewConfig.partnerLogoBottomUrl && !viewConfig.customHtmlDescription"
class="register-area__intro-area__large-content__globe-image"
:class="{'professional-globe': isProfessional}"
/>
</div>
</div>
<div class="register-area__input-area">
<div
class="register-area__input-area__container"
:class="{ 'professional-container': isProfessional }"
>
<div class="register-area__input-area__container__title-area" @click.stop="toggleDropdown">
<div class="register-area__input-area__container__title-container">
<h1 class="register-area__input-area__container__title-area__title">Get 25 GB Free</h1>
</div>
<div class="register-area__input-area__expand">
<div class="register-area__input-area__info-button">
<InfoIcon />
<p class="register-area__input-area__info-button__message">
{{ viewConfig.tooltip }}
</p>
</div>
<button
id="registerDropdown"
type="button"
aria-haspopup="listbox"
aria-roledescription="satellites-dropdown"
:aria-expanded="isDropdownShown"
class="register-area__input-area__expand__value"
>
{{ satelliteName }}
</button>
<BottomArrowIcon />
<ul v-if="isDropdownShown" v-click-outside="closeDropdown" tabindex="-1" role="listbox" class="register-area__input-area__expand__dropdown">
<li key="0" tabindex="0" role="option" class="register-area__input-area__expand__dropdown__item" @click.stop="closeDropdown">
<SelectedCheckIcon />
<span class="register-area__input-area__expand__dropdown__item__name">{{ satelliteName }}</span>
</li>
<li
v-for="(sat, index) in partneredSatellites"
:key="index + 1"
role="option"
tabindex="0"
:data-value="sat.name"
class="register-area__input-area__expand__dropdown__item"
@click="clickSatellite(sat.address)"
@keypress.enter="clickSatellite(sat.address)"
>
{{ sat.name }}
</li>
</ul>
</div>
</div>
<div class="register-area__input-area__toggle__container">
<ul class="register-area__input-area__toggle__wrapper">
<li
class="register-area__input-area__toggle__personal account-tab"
:class="{ 'active': !isProfessional }"
tabindex="0"
@click.prevent="toggleAccountType(false)"
@keydown.space.prevent="toggleAccountType(false)"
>
Personal
</li>
<li
class="register-area__input-area__toggle__professional account-tab"
:class="{ 'active': isProfessional }"
aria-roledescription="professional-label"
tabindex="0"
@click.prevent="toggleAccountType(true)"
@keydown.space.prevent="toggleAccountType(true)"
>
Business
</li>
</ul>
</div>
<div class="register-area__input-wrapper first-input">
<VInput
label="Full Name"
placeholder="Enter Full Name"
:error="fullNameError"
role-description="name"
@setData="setFullName"
/>
</div>
<div class="register-area__input-wrapper">
<VInput
label="Email Address"
placeholder="user@example.com"
:error="emailError"
role-description="email"
@setData="setEmail"
/>
</div>
<div v-if="isProfessional">
<div class="register-area__input-wrapper">
<VInput
label="Company Name"
placeholder="Acme Corp."
:error="companyNameError"
role-description="company-name"
@setData="setCompanyName"
/>
</div>
<div class="register-area__input-wrapper">
<VInput
label="Position"
placeholder="Position Title"
:error="positionError"
role-description="position"
@setData="setPosition"
/>
</div>
<div class="register-area__input-wrapper">
<SelectInput
label="Employees"
:options-list="employeeCountOptions"
@setData="setEmployeeCount"
/>
</div>
</div>
<div class="register-input">
<div class="register-area__input-wrapper">
<VInput
label="Password"
placeholder="Enter Password"
:error="passwordError"
is-password
role-description="password"
@setData="setPassword"
@showPasswordStrength="showPasswordStrength"
@hidePasswordStrength="hidePasswordStrength"
/>
<PasswordStrength
:password-string="password"
:is-shown="isPasswordStrengthShown"
/>
</div>
</div>
<div class="register-area__input-wrapper">
<VInput
label="Retype Password"
placeholder="Retype Password"
:error="repeatedPasswordError"
is-password
role-description="retype-password"
@setData="setRepeatedPassword"
/>
</div>
<AddCouponCodeInput v-if="couponCodeSignupUIEnabled" />
<div v-if="isBetaSatellite" class="register-area__input-area__container__warning">
<div class="register-area__input-area__container__warning__header">
<label class="checkmark-container">
<input tabindex="-1" type="checkbox" @change="onBetaTermsAcceptedToggled">
<span class="checkmark" :class="{'error': areBetaTermsAcceptedError}" @keydown.space.prevent="onBetaTermsAcceptedToggled" />
</label>
<h2 class="register-area__input-area__container__warning__header__label">
This is a BETA satellite
</h2>
</div>
<p class="register-area__input-area__container__warning__message">
This means any data you upload to this satellite can be
deleted at any time and your storage/bandwidth limits
can fluctuate. To use our production service please
create an account on one of our production Satellites.
<a href="https://storj.io/signup/" target="_blank" rel="noopener noreferrer">https://storj.io/signup/</a>
</p>
</div>
<div v-if="isProfessional" class="register-area__input-area__container__checkbox-area">
<label class="checkmark-container">
<input id="sales" v-model="haveSalesContact" tabindex="-1" type="checkbox">
<span tabindex="0" class="checkmark" @keydown.space.prevent="toggleCheckbox" />
</label>
<label class="register-area__input-area__container__checkbox-area__msg-box" for="sales">
<p class="register-area__input-area__container__checkbox-area__msg-box__msg">
Please have the Sales Team contact me
</p>
</label>
</div>
<div class="register-area__input-area__container__checkbox-area">
<label for="terms" class="checkmark-container">
<input id="terms" tabindex="-1" type="checkbox" @change="onTermsAcceptedToggled">
<span tabindex="0" class="checkmark" :class="{'error': isTermsAcceptedError}" @keydown.space.prevent="onTermsAcceptedToggled" />
</label>
<label class="register-area__input-area__container__checkbox-area__msg-box" for="terms">
<p class="register-area__input-area__container__checkbox-area__msg-box__msg">
I agree to the
<a class="register-area__input-area__container__checkbox-area__msg-box__msg__link" href="https://storj.io/terms-of-service/" target="_blank" rel="noopener">Terms of Service</a>
and
<a class="register-area__input-area__container__checkbox-area__msg-box__msg__link" href="https://storj.io/privacy-policy/" target="_blank" rel="noopener">Privacy Policy</a>
</p>
</label>
</div>
<VueRecaptcha
v-if="recaptchaEnabled"
ref="captcha"
:sitekey="recaptchaSiteKey"
:load-recaptcha-script="true"
size="invisible"
@verify="onCaptchaVerified"
@error="onCaptchaError"
/>
<VueHcaptcha
v-else-if="hcaptchaEnabled"
ref="captcha"
:sitekey="hcaptchaSiteKey"
:re-captcha-compat="false"
size="invisible"
@verify="onCaptchaVerified"
@error="onCaptchaError"
/>
<v-button
class="register-area__input-area__container__button"
width="100%"
height="48px"
:label="viewConfig.signupButtonLabel"
border-radius="50px"
:is-disabled="isLoading"
:on-press="onCreateClick"
>
Sign In
</v-button>
<div class="register-area__input-area__login-container">
Already have an account? <router-link :to="loginPath" class="register-area__input-area__login-container__link">Login.</router-link>
</div>
</div>
</div>
<div class="register-area__container__mobile-content">
<!-- eslint-disable-next-line vue/no-v-html -->
<div v-if="viewConfig.customHtmlDescription" class="register-area__container__mobile-content__custom-html-container" v-html="viewConfig.customHtmlDescription" />
<div v-if="!!viewConfig.partnerLogoBottomUrl" class="register-area__logo-wrapper">
<div class="register-area__logo-wrapper__container">
<img :src="viewConfig.partnerLogoBottomUrl" :srcset="viewConfig.partnerLogoBottomUrl" alt="partner logo" class="register-area__logo-wrapper__logo wide">
<div class="logo-divider" />
<LogoIcon class="logo" @click="onLogoClick" />
</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import VueRecaptcha from 'vue-recaptcha';
import VueHcaptcha from '@hcaptcha/vue-hcaptcha';
import { computed, onBeforeMount, ref } from 'vue';
import BottomArrowIcon from '../../../static/images/common/lightBottomArrow.svg';
import SelectedCheckIcon from '../../../static/images/common/selectedCheck.svg';
import LogoIcon from '../../../static/images/logo.svg';
import LogoWithPartnerIcon from '../../../static/images/partnerStorjLogo.svg';
import { AuthHttpApi } from '@/api/auth';
import { RouteConfig } from '@/router';
import { PartneredSatellite } from '@/types/common';
import { User } from '@/types/users';
import { MetaUtils } from '@/utils/meta';
import { Validator } from '@/utils/validation';
import { AnalyticsHttpApi } from '@/api/analytics';
import { useNotify, useRoute, useRouter, useStore } from '@/utils/hooks';
import SelectInput from '@/components/common/SelectInput.vue';
import PasswordStrength from '@/components/common/PasswordStrength.vue';
import VButton from '@/components/common/VButton.vue';
import VInput from '@/components/common/VInput.vue';
import AddCouponCodeInput from '@/components/common/AddCouponCodeInput.vue';
import RegisterGlobe from '@/../static/images/register/RegisterGlobe.svg';
import InfoIcon from '@/../static/images/register/info.svg';
type ViewConfig = {
title: string;
partnerUrl: string;
partnerLogoTopUrl: string;
partnerLogoBottomUrl: string;
description: string;
customHtmlDescription: string;
signupButtonLabel: string;
tooltip: string;
}
const user = ref(new User());
const viewConfig = ref<ViewConfig | null>(null);
// DCS logic
const secret = ref('');
const isTermsAccepted = ref(false);
const password = ref('');
const repeatedPassword = ref('');
// Only for beta sats (like US2).
const areBetaTermsAccepted = ref(false);
const areBetaTermsAcceptedError = ref(false);
const fullNameError = ref('');
const emailError = ref('');
const passwordError = ref('');
const repeatedPasswordError = ref('');
const companyNameError = ref('');
const employeeCountError = ref('');
const positionError = ref('');
const isTermsAcceptedError = ref(false);
const isLoading = ref(false);
const isProfessional = ref(false);
const haveSalesContact = ref(false);
const captchaError = ref(false);
const captchaResponseToken = ref('');
const recaptchaEnabled: boolean = MetaUtils.getMetaContent('registration-recaptcha-enabled') === 'true';
const recaptchaSiteKey: string = MetaUtils.getMetaContent('registration-recaptcha-site-key');
const hcaptchaEnabled: boolean = MetaUtils.getMetaContent('registration-hcaptcha-enabled') === 'true';
const hcaptchaSiteKey: string = MetaUtils.getMetaContent('registration-hcaptcha-site-key');
const isPasswordStrengthShown = ref(false);
// DCS logic
const isDropdownShown = ref(false);
// Employee Count dropdown options
const employeeCountOptions = ['1-50', '51-1000', '1001+'];
const loginPath = RouteConfig.Login.path;
const captcha = ref<VueRecaptcha | VueHcaptcha | null>(null);
const analytics = new AnalyticsHttpApi();
const auth = new AuthHttpApi();
const notify = useNotify();
const router = useRouter();
const store = useStore();
const route = useRoute();
/**
* Lifecycle hook before initial render.
* Sets up variables from route params and loads config.
*/
onBeforeMount(() => {
if (route.query.token) {
secret.value = route.query.token.toString();
}
if (route.query.partner) {
user.value.partner = route.query.partner.toString();
}
if (route.query.promo) {
user.value.signupPromoCode = route.query.promo.toString();
}
try {
const config = require('@/views/registration/registrationViewConfig.json');
viewConfig.value = user.value.partner && config[user.value.partner] ? config[user.value.partner] : config['default'];
} catch (e) {
notify.error('No configuration file for registration page.', null);
}
});
/**
* Redirects to chosen satellite.
*/
function clickSatellite(address): void {
window.location.href = address;
}
/**
* Toggles satellite selection dropdown visibility (Tardigrade).
*/
function toggleDropdown(): void {
isDropdownShown.value = !isDropdownShown.value;
}
/**
* Closes satellite selection dropdown (Tardigrade).
*/
function closeDropdown(): void {
isDropdownShown.value = false;
}
/**
* Makes password strength container visible.
*/
function showPasswordStrength(): void {
isPasswordStrengthShown.value = true;
}
/**
* Hides password strength container.
*/
function hidePasswordStrength(): void {
isPasswordStrengthShown.value = false;
}
/**
* Validates input fields and proceeds user creation.
*/
async function onCreateClick(): Promise<void> {
if (isLoading.value && !isDropdownShown.value) {
return;
}
let activeElement = document.activeElement;
if (activeElement && activeElement.id === 'registerDropdown') return;
if (isDropdownShown.value) {
isDropdownShown.value = false;
return;
}
await createUser();
}
/**
* Redirects to storj.io homepage.
*/
function onLogoClick(): void {
window.location.href = MetaUtils.getMetaContent('homepage-url');
}
/**
* Sets user's email field from value string.
*/
function setEmail(value: string): void {
user.value.email = value.trim();
emailError.value = '';
}
/**
* Sets user's full name field from value string.
*/
function setFullName(value: string): void {
user.value.fullName = value.trim();
fullNameError.value = '';
}
/**
* Sets user's password field from value string.
*/
function setPassword(value: string): void {
user.value.password = value;
password.value = value;
passwordError.value = '';
}
/**
* Sets user's repeat password field from value string.
*/
function setRepeatedPassword(value: string): void {
repeatedPassword.value = value;
repeatedPasswordError.value = '';
}
/**
* Name of the current satellite.
*/
const satelliteName = computed((): string => {
return store.state.appStateModule.satelliteName;
});
/**
* Information about partnered satellites, including name and signup link.
*/
const partneredSatellites = computed((): PartneredSatellite[] => {
const satellites = store.state.appStateModule.partneredSatellites;
return satellites.map((s: PartneredSatellite) => {
s.address = `${s.address}/signup`;
if (user.value.partner) {
s.address = `${s.address}?partner=${user.value.partner}`;
}
return s;
});
});
/**
* Indicates if satellite is in beta.
*/
const isBetaSatellite = computed((): boolean => {
return store.state.appStateModule.isBetaSatellite;
});
/**
* Indicates if coupon code ui is enabled
*/
const couponCodeSignupUIEnabled = computed((): boolean => {
return store.state.appStateModule.couponCodeSigunpUIEnabled;
});
/**
* Sets user's company name field from value string.
*/
function setCompanyName(value: string): void {
user.value.companyName = value.trim();
companyNameError.value = '';
}
/**
* Sets user's company size field from value string.
*/
function setEmployeeCount(value: string): void {
user.value.employeeCount = value;
employeeCountError.value = '';
}
/**
* Sets user's position field from value string.
*/
function setPosition(value: string): void {
user.value.position = value.trim();
positionError.value = '';
}
/**
* toggle user account type
*/
function toggleAccountType(value: boolean): void {
isProfessional.value = value;
}
/**
* Handles captcha verification response.
*/
function onCaptchaVerified(response: string): void {
captchaResponseToken.value = response;
captchaError.value = false;
createUser();
}
/**
* Handles captcha error.
*/
function onCaptchaError(): void {
captchaResponseToken.value = '';
notify.error('The captcha encountered an error. Please try again.', null);
}
/**
* Executes when the Terms of Service checkbox has been toggled.
*/
function onTermsAcceptedToggled(event: KeyboardEvent): void {
if (event.key === ' ' || event.code === 'Space' || event.keyCode === 32) {
const checkbox = ((event.target as HTMLElement).parentElement as HTMLLabelElement).control as HTMLInputElement;
checkbox.checked = !checkbox.checked;
checkbox.setAttribute('checked', String(checkbox.checked));
isTermsAccepted.value = checkbox.checked;
isTermsAcceptedError.value = false;
} else {
isTermsAccepted.value = (event.target as HTMLInputElement).checked;
isTermsAcceptedError.value = false;
}
}
/**
* Executes when the beta satellite terms checkbox has been toggled.
*/
function onBetaTermsAcceptedToggled(event: KeyboardEvent): void {
if (event.key === ' ' || event.code === 'Space' || event.keyCode === 32) {
const checkbox = ((event.target as HTMLElement).parentElement as HTMLLabelElement).control as HTMLInputElement;
checkbox.checked = !checkbox.checked;
checkbox.setAttribute('checked', String(checkbox.checked));
areBetaTermsAccepted.value = checkbox.checked;
isTermsAcceptedError.value = false;
} else {
areBetaTermsAccepted.value = (event.target as HTMLInputElement).checked;
areBetaTermsAcceptedError.value = false;
}
}
/**
* Executes when the space bar is pressed on a focused checkbox.
*/
function toggleCheckbox(event: Event): void {
const checkbox = ((event.target as HTMLElement).parentElement as HTMLLabelElement).control as HTMLInputElement;
checkbox.checked = !checkbox.checked;
checkbox.setAttribute('checked', String(checkbox.checked));
}
/**
* Validates input values to satisfy expected rules.
*/
function validateFields(): boolean {
let isNoErrors = true;
if (!user.value.fullName) {
fullNameError.value = 'Name can\'t be empty';
isNoErrors = false;
}
if (!isEmailValid()) {
emailError.value = 'Invalid Email';
isNoErrors = false;
}
if (!Validator.password(password.value)) {
passwordError.value = 'Invalid Password';
isNoErrors = false;
}
if (isProfessional.value) {
if (!user.value.companyName) {
companyNameError.value = 'No Company Name filled in';
isNoErrors = false;
}
if (!user.value.position) {
positionError.value = 'No Position filled in';
isNoErrors = false;
}
if (!user.value.employeeCount) {
employeeCountError.value = 'No Company Size filled in';
isNoErrors = false;
}
}
if (repeatedPassword.value !== password.value) {
repeatedPasswordError.value = 'Password doesn\'t match';
isNoErrors = false;
}
if (!isTermsAccepted.value) {
isTermsAcceptedError.value = true;
isNoErrors = false;
}
// only for beta US2 sats.
if (isBetaSatellite.value && !areBetaTermsAccepted.value) {
areBetaTermsAcceptedError.value = true;
isNoErrors = false;
}
if (user.value.partner.length > 100) {
notify.error('Partner must be less than or equal to 100 characters', null);
return false;
}
if (user.value.signupPromoCode.length > 100) {
notify.error('Promo code must be less than or equal to 100 characters', null);
return false;
}
return isNoErrors;
}
/**
* Detect if user uses Brave browser
*/
async function detectBraveBrowser(): Promise<boolean> {
return (navigator['brave'] && await navigator['brave'].isBrave() || false);
}
/**
* Validates email string.
* We'll have this email validation for new users instead of using regular Validator.email method because of backwards compatibility.
* We don't want to block old users who managed to create and verify their accounts with some weird email addresses.
*/
function isEmailValid(): boolean {
// This regular expression fulfills our needs to validate international emails.
// It was built according to RFC 5322 and then extended to include international characters using these resources
// https://emailregex.com/
// https://awik.io/international-email-address-validation-javascript/
// eslint-disable-next-line no-misleading-character-class
const regex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u0080-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF\u1000-\u109F\u10A0-\u10FF\u1100-\u11FF\u1200-\u137F\u1380-\u139F\u13A0-\u13FF\u1400-\u167F\u1680-\u169F\u16A0-\u16FF\u1700-\u171F\u1720-\u173F\u1740-\u175F\u1760-\u177F\u1780-\u17FF\u1800-\u18AF\u1900-\u194F\u1950-\u197F\u1980-\u19DF\u19E0-\u19FF\u1A00-\u1A1F\u1B00-\u1B7F\u1D00-\u1D7F\u1D80-\u1DBF\u1DC0-\u1DFF\u1E00-\u1EFF\u1F00-\u1FFF\u20D0-\u20FF\u2100-\u214F\u2C00-\u2C5F\u2C60-\u2C7F\u2C80-\u2CFF\u2D00-\u2D2F\u2D30-\u2D7F\u2D80-\u2DDF\u2F00-\u2FDF\u2FF0-\u2FFF\u3040-\u309F\u30A0-\u30FF\u3100-\u312F\u3130-\u318F\u3190-\u319F\u31C0-\u31EF\u31F0-\u31FF\u3200-\u32FF\u3300-\u33FF\u3400-\u4DBF\u4DC0-\u4DFF\u4E00-\u9FFF\uA000-\uA48F\uA490-\uA4CF\uA700-\uA71F\uA800-\uA82F\uA840-\uA87F\uAC00-\uD7AF\uF900-\uFAFF]+\.)+[a-zA-Z\u0080-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF\u1000-\u109F\u10A0-\u10FF\u1100-\u11FF\u1200-\u137F\u1380-\u139F\u13A0-\u13FF\u1400-\u167F\u1680-\u169F\u16A0-\u16FF\u1700-\u171F\u1720-\u173F\u1740-\u175F\u1760-\u177F\u1780-\u17FF\u1800-\u18AF\u1900-\u194F\u1950-\u197F\u1980-\u19DF\u19E0-\u19FF\u1A00-\u1A1F\u1B00-\u1B7F\u1D00-\u1D7F\u1D80-\u1DBF\u1DC0-\u1DFF\u1E00-\u1EFF\u1F00-\u1FFF\u20D0-\u20FF\u2100-\u214F\u2C00-\u2C5F\u2C60-\u2C7F\u2C80-\u2CFF\u2D00-\u2D2F\u2D30-\u2D7F\u2D80-\u2DDF\u2F00-\u2FDF\u2FF0-\u2FFF\u3040-\u309F\u30A0-\u30FF\u3100-\u312F\u3130-\u318F\u3190-\u319F\u31C0-\u31EF\u31F0-\u31FF\u3200-\u32FF\u3300-\u33FF\u3400-\u4DBF\u4DC0-\u4DFF\u4E00-\u9FFF\uA000-\uA48F\uA490-\uA4CF\uA700-\uA71F\uA800-\uA82F\uA840-\uA87F\uAC00-\uD7AF\uF900-\uFAFF]{2,}))$/;
return regex.test(user.value.email);
}
/**
* Creates user and toggles successful registration area visibility.
*/
async function createUser(): Promise<void> {
let activeElement = document.activeElement;
if (activeElement && activeElement.classList.contains('account-tab')) {
return;
}
if (!validateFields()) {
return;
}
if (captcha.value && !captchaResponseToken.value) {
captcha.value?.execute();
return;
}
isLoading.value = true;
user.value.isProfessional = isProfessional.value;
user.value.haveSalesContact = haveSalesContact.value;
try {
await auth.register(user.value, secret.value, captchaResponseToken.value);
// Brave browser conversions are tracked via the RegisterSuccess path in the satellite app
// signups outside of the brave browser may use a configured URL to track conversions
// if the URL is not configured, the RegisterSuccess path will be used for non-Brave browsers
const internalRegisterSuccessPath = RouteConfig.RegisterSuccess.path;
const configuredRegisterSuccessPath = MetaUtils.getMetaContent('optional-signup-success-url') || internalRegisterSuccessPath;
const nonBraveSuccessPath = `${configuredRegisterSuccessPath}?email=${encodeURIComponent(user.value.email)}`;
const braveSuccessPath = `${internalRegisterSuccessPath}?email=${encodeURIComponent(user.value.email)}`;
await detectBraveBrowser() ? await router.push(braveSuccessPath) : window.location.href = nonBraveSuccessPath;
} catch (error) {
await notify.error(error.message, null);
}
captcha.value?.reset();
captchaResponseToken.value = '';
isLoading.value = false;
}
</script>
<style scoped lang="scss">
%subtitle-text {
max-width: 550px;
margin-top: 27px;
font-size: 16px;
font-family: 'font_regular', sans-serif;
line-height: 24px;
text-align: left;
}
.logo-divider {
border-left: 1px solid var(--c-light-blue-2);
height: 40px;
margin: 0 10px;
}
.register-area {
display: flex;
flex-direction: column;
align-items: center;
font-family: 'font_regular', sans-serif;
background-color: #f5f6fa;
box-sizing: border-box;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow-y: scroll;
padding-top: 80px;
height: 100vh;
&__logo-wrapper {
display: flex;
align-items: center;
justify-content: flex-start;
height: 52px;
margin-bottom: 32px;
&__container {
display: flex;
align-items: center;
justify-content: flex-end;
height: 100%;
}
&__logo {
height: 66px;
max-width: 250px;
max-height: 66px;
&.wide {
object-fit: cover;
width: auto;
height: 56px;
max-width: unset;
@media screen and (max-width: 1024px) {
object-fit: contain;
max-width: 45%;
}
}
}
&.bottom {
margin: 27px 0 0;
}
}
&__input-wrapper.first-input {
margin-top: 10px;
}
&__container {
display: flex;
width: 75%;
justify-content: center;
max-width: 1500px;
@media screen and (max-width: 1600px) {
width: 90%;
}
&__mobile-content {
@media screen and (min-width: 1025px) {
display: none;
}
.register-area__logo-wrapper {
display: block;
margin-top: 24px;
&__container {
justify-content: center;
}
}
&__custom-html-container {
margin-top: 27px;
:deep(p) {
@extend %subtitle-text;
text-align: center;
strong {
font-family: 'font_bold', sans-serif;
}
a {
text-decoration: underline !important;
color: inherit !important;
}
}
:deep(ol) {
@extend %subtitle-text;
list-style-position: inside;
}
}
}
}
&__intro-area {
box-sizing: border-box;
overflow: hidden;
padding: 40px 0 60px;
max-width: 40%;
margin-right: 80px;
&__wrapper {
width: 80%;
}
&__title {
font-family: 'font_bold', sans-serif;
font-size: 48px;
font-style: normal;
font-weight: 800;
line-height: 59px;
letter-spacing: 0;
text-align: left;
}
&__sub-title {
@extend %subtitle-text;
}
&__large-content {
&__custom-html-container {
padding-bottom: 27px;
:deep(p) {
@extend %subtitle-text;
strong {
font-family: 'font_bold', sans-serif;
}
a {
text-decoration: underline !important;
color: inherit !important;
}
}
:deep(ol) {
@extend %subtitle-text;
list-style-position: inside;
}
}
&__globe-image {
position: relative;
top: 140px;
left: 40px;
}
&__globe-image.professional-globe {
top: 110px;
left: 40px;
}
}
}
&__input-area {
box-sizing: border-box;
padding: 60px 80px;
background-color: #fff;
border-radius: 20px;
width: 50%;
&__expand {
display: flex;
align-items: center;
cursor: pointer;
position: relative;
&__value {
font-family: 'font_regular', sans-serif;
font-weight: 700;
font-size: 16px;
line-height: 21px;
color: #afb7c1;
margin-right: 10px;
border: none;
cursor: pointer;
background: transparent;
}
&__dropdown {
position: absolute;
top: 35px;
right: 0;
background-color: #fff;
z-index: 1000;
border: 1px solid #c5cbdb;
box-shadow: 0 8px 34px rgb(161 173 185 / 41%);
border-radius: 6px;
min-width: 250px;
&__item {
display: flex;
align-items: center;
justify-content: flex-start;
padding: 12px 25px;
font-size: 14px;
line-height: 20px;
color: #7e8b9c;
cursor: pointer;
text-decoration: none;
&__name {
font-family: 'font_bold', sans-serif;