@ttoss/react-auth 1.6.12 → 1.6.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +29 -7
- package/dist/index.js +29 -7
- package/i18n/compiled/en.json +58 -4
- package/i18n/lang/en.json +40 -4
- package/package.json +7 -7
- package/src/AuthCard.tsx +2 -1
- package/src/AuthConfirmSignUp.tsx +6 -4
- package/src/AuthRecoveryPassword.tsx +92 -0
- package/src/AuthSignIn.tsx +13 -4
- package/src/AuthSignUp.tsx +14 -3
package/dist/esm/index.js
CHANGED
|
@@ -109,7 +109,7 @@ var AuthCard = ({
|
|
|
109
109
|
} = useNotifications();
|
|
110
110
|
return /* @__PURE__ */jsxs(Box, {
|
|
111
111
|
sx: {
|
|
112
|
-
|
|
112
|
+
width: "100%",
|
|
113
113
|
border: "default",
|
|
114
114
|
borderColor: "primary",
|
|
115
115
|
paddingX: "2xl",
|
|
@@ -151,6 +151,7 @@ var AuthCard = ({
|
|
|
151
151
|
textAlign: "center",
|
|
152
152
|
display: "initial"
|
|
153
153
|
},
|
|
154
|
+
loading: isLoading,
|
|
154
155
|
children: buttonLabel
|
|
155
156
|
}), extraButton]
|
|
156
157
|
})]
|
|
@@ -525,16 +526,16 @@ var AuthSignIn = ({
|
|
|
525
526
|
}, [setNotifications]);
|
|
526
527
|
const schema = yup2.object().shape({
|
|
527
528
|
email: yup2.string().required(intl.formatMessage({
|
|
528
|
-
id: "
|
|
529
|
+
id: "d1YCuH",
|
|
529
530
|
defaultMessage: [{
|
|
530
531
|
"type": 0,
|
|
531
|
-
"value": "
|
|
532
|
+
"value": "Enter your email address"
|
|
532
533
|
}]
|
|
533
534
|
})).email(intl.formatMessage({
|
|
534
|
-
id: "
|
|
535
|
+
id: "9cApwd",
|
|
535
536
|
defaultMessage: [{
|
|
536
537
|
"type": 0,
|
|
537
|
-
"value": "
|
|
538
|
+
"value": "Please, insert a valid e-mail"
|
|
538
539
|
}]
|
|
539
540
|
})),
|
|
540
541
|
password: yup2.string().required(intl.formatMessage({
|
|
@@ -563,12 +564,17 @@ var AuthSignIn = ({
|
|
|
563
564
|
|
|
564
565
|
const formMethods = useForm2({
|
|
565
566
|
defaultValues,
|
|
567
|
+
mode: "onBlur",
|
|
566
568
|
resolver: yupResolver2(schema)
|
|
567
569
|
});
|
|
568
570
|
const onSubmitForm = data => {
|
|
569
571
|
return onSignIn(data);
|
|
570
572
|
};
|
|
571
573
|
return /* @__PURE__ */jsx5(Form2, {
|
|
574
|
+
sx: {
|
|
575
|
+
maxWidth: "390px",
|
|
576
|
+
width: "100%"
|
|
577
|
+
},
|
|
572
578
|
...formMethods,
|
|
573
579
|
onSubmit: onSubmitForm,
|
|
574
580
|
children: /* @__PURE__ */jsxs2(AuthCard, {
|
|
@@ -634,6 +640,9 @@ var AuthSignIn = ({
|
|
|
634
640
|
marginTop: "lg"
|
|
635
641
|
},
|
|
636
642
|
children: /* @__PURE__ */jsx5(Text, {
|
|
643
|
+
sx: {
|
|
644
|
+
marginLeft: "auto"
|
|
645
|
+
},
|
|
637
646
|
as: Link,
|
|
638
647
|
onClick: onForgotPassword,
|
|
639
648
|
children: intl.formatMessage({
|
|
@@ -671,10 +680,10 @@ var AuthSignUp = ({
|
|
|
671
680
|
}, [setNotifications]);
|
|
672
681
|
const schema = yup3.object().shape({
|
|
673
682
|
email: yup3.string().required(intl.formatMessage({
|
|
674
|
-
id: "
|
|
683
|
+
id: "d1YCuH",
|
|
675
684
|
defaultMessage: [{
|
|
676
685
|
"type": 0,
|
|
677
|
-
"value": "
|
|
686
|
+
"value": "Enter your email address"
|
|
678
687
|
}]
|
|
679
688
|
})).email(intl.formatMessage({
|
|
680
689
|
id: "OhDL0i",
|
|
@@ -703,6 +712,12 @@ var AuthSignUp = ({
|
|
|
703
712
|
}]
|
|
704
713
|
}, {
|
|
705
714
|
value: PASSWORD_MINIMUM_LENGTH
|
|
715
|
+
})).oneOf([yup3.ref("confirmPassword")], intl.formatMessage({
|
|
716
|
+
id: "SPiKja",
|
|
717
|
+
defaultMessage: [{
|
|
718
|
+
"type": 0,
|
|
719
|
+
"value": "Password requirements not met"
|
|
720
|
+
}]
|
|
706
721
|
})).trim(),
|
|
707
722
|
confirmPassword: yup3.string().required(intl.formatMessage({
|
|
708
723
|
id: "NJ57Qj",
|
|
@@ -726,6 +741,10 @@ var AuthSignUp = ({
|
|
|
726
741
|
return onSignUp(data);
|
|
727
742
|
};
|
|
728
743
|
return /* @__PURE__ */jsx6(Form3, {
|
|
744
|
+
sx: {
|
|
745
|
+
maxWidth: "390px",
|
|
746
|
+
width: "100%"
|
|
747
|
+
},
|
|
729
748
|
...formMethods,
|
|
730
749
|
onSubmit: onSubmitForm,
|
|
731
750
|
children: /* @__PURE__ */jsxs3(AuthCard, {
|
|
@@ -745,6 +764,9 @@ var AuthSignUp = ({
|
|
|
745
764
|
}),
|
|
746
765
|
isValidForm: formMethods.formState.isValid,
|
|
747
766
|
extraButton: /* @__PURE__ */jsx6(Text2, {
|
|
767
|
+
sx: {
|
|
768
|
+
cursor: "pointer"
|
|
769
|
+
},
|
|
748
770
|
onClick: onReturnToSignIn,
|
|
749
771
|
as: Link2,
|
|
750
772
|
children: intl.formatMessage({
|
package/dist/index.js
CHANGED
|
@@ -153,7 +153,7 @@ var AuthCard = ({
|
|
|
153
153
|
} = (0, import_react_notifications.useNotifications)();
|
|
154
154
|
return /* @__PURE__ */(0, import_jsx_runtime2.jsxs)(import_ui.Box, {
|
|
155
155
|
sx: {
|
|
156
|
-
|
|
156
|
+
width: "100%",
|
|
157
157
|
border: "default",
|
|
158
158
|
borderColor: "primary",
|
|
159
159
|
paddingX: "2xl",
|
|
@@ -195,6 +195,7 @@ var AuthCard = ({
|
|
|
195
195
|
textAlign: "center",
|
|
196
196
|
display: "initial"
|
|
197
197
|
},
|
|
198
|
+
loading: isLoading,
|
|
198
199
|
children: buttonLabel
|
|
199
200
|
}), extraButton]
|
|
200
201
|
})]
|
|
@@ -569,16 +570,16 @@ var AuthSignIn = ({
|
|
|
569
570
|
}, [setNotifications]);
|
|
570
571
|
const schema = import_forms2.yup.object().shape({
|
|
571
572
|
email: import_forms2.yup.string().required(intl.formatMessage({
|
|
572
|
-
id: "
|
|
573
|
+
id: "d1YCuH",
|
|
573
574
|
defaultMessage: [{
|
|
574
575
|
"type": 0,
|
|
575
|
-
"value": "
|
|
576
|
+
"value": "Enter your email address"
|
|
576
577
|
}]
|
|
577
578
|
})).email(intl.formatMessage({
|
|
578
|
-
id: "
|
|
579
|
+
id: "9cApwd",
|
|
579
580
|
defaultMessage: [{
|
|
580
581
|
"type": 0,
|
|
581
|
-
"value": "
|
|
582
|
+
"value": "Please, insert a valid e-mail"
|
|
582
583
|
}]
|
|
583
584
|
})),
|
|
584
585
|
password: import_forms2.yup.string().required(intl.formatMessage({
|
|
@@ -607,12 +608,17 @@ var AuthSignIn = ({
|
|
|
607
608
|
|
|
608
609
|
const formMethods = (0, import_forms2.useForm)({
|
|
609
610
|
defaultValues,
|
|
611
|
+
mode: "onBlur",
|
|
610
612
|
resolver: (0, import_forms2.yupResolver)(schema)
|
|
611
613
|
});
|
|
612
614
|
const onSubmitForm = data => {
|
|
613
615
|
return onSignIn(data);
|
|
614
616
|
};
|
|
615
617
|
return /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_forms2.Form, {
|
|
618
|
+
sx: {
|
|
619
|
+
maxWidth: "390px",
|
|
620
|
+
width: "100%"
|
|
621
|
+
},
|
|
616
622
|
...formMethods,
|
|
617
623
|
onSubmit: onSubmitForm,
|
|
618
624
|
children: /* @__PURE__ */(0, import_jsx_runtime5.jsxs)(AuthCard, {
|
|
@@ -678,6 +684,9 @@ var AuthSignIn = ({
|
|
|
678
684
|
marginTop: "lg"
|
|
679
685
|
},
|
|
680
686
|
children: /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_ui3.Text, {
|
|
687
|
+
sx: {
|
|
688
|
+
marginLeft: "auto"
|
|
689
|
+
},
|
|
681
690
|
as: import_ui3.Link,
|
|
682
691
|
onClick: onForgotPassword,
|
|
683
692
|
children: intl.formatMessage({
|
|
@@ -715,10 +724,10 @@ var AuthSignUp = ({
|
|
|
715
724
|
}, [setNotifications]);
|
|
716
725
|
const schema = import_forms3.yup.object().shape({
|
|
717
726
|
email: import_forms3.yup.string().required(intl.formatMessage({
|
|
718
|
-
id: "
|
|
727
|
+
id: "d1YCuH",
|
|
719
728
|
defaultMessage: [{
|
|
720
729
|
"type": 0,
|
|
721
|
-
"value": "
|
|
730
|
+
"value": "Enter your email address"
|
|
722
731
|
}]
|
|
723
732
|
})).email(intl.formatMessage({
|
|
724
733
|
id: "OhDL0i",
|
|
@@ -747,6 +756,12 @@ var AuthSignUp = ({
|
|
|
747
756
|
}]
|
|
748
757
|
}, {
|
|
749
758
|
value: PASSWORD_MINIMUM_LENGTH
|
|
759
|
+
})).oneOf([import_forms3.yup.ref("confirmPassword")], intl.formatMessage({
|
|
760
|
+
id: "SPiKja",
|
|
761
|
+
defaultMessage: [{
|
|
762
|
+
"type": 0,
|
|
763
|
+
"value": "Password requirements not met"
|
|
764
|
+
}]
|
|
750
765
|
})).trim(),
|
|
751
766
|
confirmPassword: import_forms3.yup.string().required(intl.formatMessage({
|
|
752
767
|
id: "NJ57Qj",
|
|
@@ -770,6 +785,10 @@ var AuthSignUp = ({
|
|
|
770
785
|
return onSignUp(data);
|
|
771
786
|
};
|
|
772
787
|
return /* @__PURE__ */(0, import_jsx_runtime6.jsx)(import_forms3.Form, {
|
|
788
|
+
sx: {
|
|
789
|
+
maxWidth: "390px",
|
|
790
|
+
width: "100%"
|
|
791
|
+
},
|
|
773
792
|
...formMethods,
|
|
774
793
|
onSubmit: onSubmitForm,
|
|
775
794
|
children: /* @__PURE__ */(0, import_jsx_runtime6.jsxs)(AuthCard, {
|
|
@@ -789,6 +808,9 @@ var AuthSignUp = ({
|
|
|
789
808
|
}),
|
|
790
809
|
isValidForm: formMethods.formState.isValid,
|
|
791
810
|
extraButton: /* @__PURE__ */(0, import_jsx_runtime6.jsx)(import_ui4.Text, {
|
|
811
|
+
sx: {
|
|
812
|
+
cursor: "pointer"
|
|
813
|
+
},
|
|
792
814
|
onClick: onReturnToSignIn,
|
|
793
815
|
as: import_ui4.Link,
|
|
794
816
|
children: intl.formatMessage({
|
package/i18n/compiled/en.json
CHANGED
|
@@ -17,6 +17,24 @@
|
|
|
17
17
|
"value": "Email"
|
|
18
18
|
}
|
|
19
19
|
],
|
|
20
|
+
"5oOshZ": [
|
|
21
|
+
{
|
|
22
|
+
"type": 0,
|
|
23
|
+
"value": "Enter your email address"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"6PdOcy": [
|
|
27
|
+
{
|
|
28
|
+
"type": 0,
|
|
29
|
+
"value": "Cancel"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"9cApwd": [
|
|
33
|
+
{
|
|
34
|
+
"type": 0,
|
|
35
|
+
"value": "Please, insert a valid e-mail"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
20
38
|
"BtK6KR": [
|
|
21
39
|
{
|
|
22
40
|
"type": 0,
|
|
@@ -73,6 +91,24 @@
|
|
|
73
91
|
"value": " characters"
|
|
74
92
|
}
|
|
75
93
|
],
|
|
94
|
+
"S4bbEj": [
|
|
95
|
+
{
|
|
96
|
+
"type": 0,
|
|
97
|
+
"value": "Recovering Password"
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
"SPiKja": [
|
|
101
|
+
{
|
|
102
|
+
"type": 0,
|
|
103
|
+
"value": "Password requirements not met"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"SnONhb": [
|
|
107
|
+
{
|
|
108
|
+
"type": 0,
|
|
109
|
+
"value": "Please, insert a valid e-mail"
|
|
110
|
+
}
|
|
111
|
+
],
|
|
76
112
|
"TZ4WUk": [
|
|
77
113
|
{
|
|
78
114
|
"type": 0,
|
|
@@ -105,12 +141,24 @@
|
|
|
105
141
|
"value": "Passwords are not the same"
|
|
106
142
|
}
|
|
107
143
|
],
|
|
144
|
+
"XreZg+": [
|
|
145
|
+
{
|
|
146
|
+
"type": 0,
|
|
147
|
+
"value": "Registered Email"
|
|
148
|
+
}
|
|
149
|
+
],
|
|
108
150
|
"cGR2eI": [
|
|
109
151
|
{
|
|
110
152
|
"type": 0,
|
|
111
153
|
"value": "Confirmation"
|
|
112
154
|
}
|
|
113
155
|
],
|
|
156
|
+
"d1YCuH": [
|
|
157
|
+
{
|
|
158
|
+
"type": 0,
|
|
159
|
+
"value": "Enter your email address"
|
|
160
|
+
}
|
|
161
|
+
],
|
|
114
162
|
"kdFYba": [
|
|
115
163
|
{
|
|
116
164
|
"type": 0,
|
|
@@ -123,16 +171,22 @@
|
|
|
123
171
|
"value": "Confirm password"
|
|
124
172
|
}
|
|
125
173
|
],
|
|
126
|
-
"
|
|
174
|
+
"lZvoYL": [
|
|
127
175
|
{
|
|
128
176
|
"type": 0,
|
|
129
|
-
"value": "Sign up"
|
|
177
|
+
"value": "Sign up now"
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
"mZzmNV": [
|
|
181
|
+
{
|
|
182
|
+
"type": 0,
|
|
183
|
+
"value": "Recover Password"
|
|
130
184
|
}
|
|
131
185
|
],
|
|
132
|
-
"
|
|
186
|
+
"oayEC3": [
|
|
133
187
|
{
|
|
134
188
|
"type": 0,
|
|
135
|
-
"value": "
|
|
189
|
+
"value": "Sign up"
|
|
136
190
|
}
|
|
137
191
|
],
|
|
138
192
|
"rx8HF/": [
|
package/i18n/lang/en.json
CHANGED
|
@@ -11,6 +11,18 @@
|
|
|
11
11
|
"defaultMessage": "Email",
|
|
12
12
|
"description": "Email label."
|
|
13
13
|
},
|
|
14
|
+
"5oOshZ": {
|
|
15
|
+
"defaultMessage": "Enter your email address",
|
|
16
|
+
"description": "Required field."
|
|
17
|
+
},
|
|
18
|
+
"6PdOcy": {
|
|
19
|
+
"defaultMessage": "Cancel",
|
|
20
|
+
"description": "Cancel"
|
|
21
|
+
},
|
|
22
|
+
"9cApwd": {
|
|
23
|
+
"defaultMessage": "Please, insert a valid e-mail",
|
|
24
|
+
"description": "Invalid email."
|
|
25
|
+
},
|
|
14
26
|
"BtK6KR": {
|
|
15
27
|
"defaultMessage": "Forgot password?",
|
|
16
28
|
"description": "Forgot password?"
|
|
@@ -43,6 +55,18 @@
|
|
|
43
55
|
"defaultMessage": "Minimum {value} characters",
|
|
44
56
|
"description": "Minimum {value} characters."
|
|
45
57
|
},
|
|
58
|
+
"S4bbEj": {
|
|
59
|
+
"defaultMessage": "Recovering Password",
|
|
60
|
+
"description": "Recovering Password"
|
|
61
|
+
},
|
|
62
|
+
"SPiKja": {
|
|
63
|
+
"defaultMessage": "Password requirements not met",
|
|
64
|
+
"description": "Password requirements not met"
|
|
65
|
+
},
|
|
66
|
+
"SnONhb": {
|
|
67
|
+
"defaultMessage": "Please, insert a valid e-mail",
|
|
68
|
+
"description": "Please, insert a valid e-mail"
|
|
69
|
+
},
|
|
46
70
|
"TZ4WUk": {
|
|
47
71
|
"defaultMessage": "Password requires {value} characters",
|
|
48
72
|
"description": "Password must be at least {value} characters long."
|
|
@@ -59,10 +83,18 @@
|
|
|
59
83
|
"defaultMessage": "Passwords are not the same",
|
|
60
84
|
"description": "Passwords are not the same"
|
|
61
85
|
},
|
|
86
|
+
"XreZg+": {
|
|
87
|
+
"defaultMessage": "Registered Email",
|
|
88
|
+
"description": "Registered Email"
|
|
89
|
+
},
|
|
62
90
|
"cGR2eI": {
|
|
63
91
|
"defaultMessage": "Confirmation",
|
|
64
92
|
"description": "Confirmation"
|
|
65
93
|
},
|
|
94
|
+
"d1YCuH": {
|
|
95
|
+
"defaultMessage": "Enter your email address",
|
|
96
|
+
"description": "Email is a required field."
|
|
97
|
+
},
|
|
66
98
|
"kdFYba": {
|
|
67
99
|
"defaultMessage": "Password field is required",
|
|
68
100
|
"description": "Password is required."
|
|
@@ -71,14 +103,18 @@
|
|
|
71
103
|
"defaultMessage": "Confirm password",
|
|
72
104
|
"description": "Confirm Password label."
|
|
73
105
|
},
|
|
106
|
+
"lZvoYL": {
|
|
107
|
+
"defaultMessage": "Sign up now",
|
|
108
|
+
"description": "Sign up now"
|
|
109
|
+
},
|
|
110
|
+
"mZzmNV": {
|
|
111
|
+
"defaultMessage": "Recover Password",
|
|
112
|
+
"description": "Recover Password"
|
|
113
|
+
},
|
|
74
114
|
"oayEC3": {
|
|
75
115
|
"defaultMessage": "Sign up",
|
|
76
116
|
"description": "Title on sign up."
|
|
77
117
|
},
|
|
78
|
-
"r+QgO+": {
|
|
79
|
-
"defaultMessage": "Email field is required",
|
|
80
|
-
"description": "Email is a required field."
|
|
81
|
-
},
|
|
82
118
|
"rx8HF/": {
|
|
83
119
|
"defaultMessage": "I’m already registered",
|
|
84
120
|
"description": "Link to sign in on sign up."
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/react-auth",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.14",
|
|
4
4
|
"description": "ttoss authentication module for React apps.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@xstate/react": "^3.2.2",
|
|
21
21
|
"xstate": "^4.37.2",
|
|
22
|
-
"@ttoss/forms": "^0.17.
|
|
22
|
+
"@ttoss/forms": "^0.17.12"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"aws-amplify": "^5.0.0",
|
|
26
26
|
"react": ">=16.8.0",
|
|
27
27
|
"@ttoss/react-i18n": "^1.22.1",
|
|
28
|
-
"@ttoss/react-notifications": "^1.22.
|
|
29
|
-
"@ttoss/ui": "^1.36.
|
|
28
|
+
"@ttoss/react-notifications": "^1.22.14",
|
|
29
|
+
"@ttoss/ui": "^1.36.11"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/react": "^18.2.6",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"@ttoss/config": "^1.30.0",
|
|
38
38
|
"@ttoss/i18n-cli": "^0.5.0",
|
|
39
39
|
"@ttoss/react-i18n": "^1.22.1",
|
|
40
|
-
"@ttoss/react-notifications": "^1.22.
|
|
41
|
-
"@ttoss/
|
|
42
|
-
"@ttoss/
|
|
40
|
+
"@ttoss/react-notifications": "^1.22.14",
|
|
41
|
+
"@ttoss/ui": "^1.36.11",
|
|
42
|
+
"@ttoss/test-utils": "^1.23.1"
|
|
43
43
|
},
|
|
44
44
|
"keywords": [
|
|
45
45
|
"React",
|
package/src/AuthCard.tsx
CHANGED
|
@@ -35,7 +35,7 @@ export const AuthCard = ({
|
|
|
35
35
|
return (
|
|
36
36
|
<Box
|
|
37
37
|
sx={{
|
|
38
|
-
|
|
38
|
+
width: '100%',
|
|
39
39
|
border: 'default',
|
|
40
40
|
borderColor: 'primary',
|
|
41
41
|
paddingX: '2xl',
|
|
@@ -82,6 +82,7 @@ export const AuthCard = ({
|
|
|
82
82
|
variant="accent"
|
|
83
83
|
disabled={isLoading || !isValidForm}
|
|
84
84
|
sx={{ textAlign: 'center', display: 'initial' }}
|
|
85
|
+
loading={isLoading}
|
|
85
86
|
>
|
|
86
87
|
{buttonLabel}
|
|
87
88
|
</Button>
|
|
@@ -3,13 +3,15 @@ import { Form, FormFieldInput, useForm, yup, yupResolver } from '@ttoss/forms';
|
|
|
3
3
|
import { useI18n } from '@ttoss/react-i18n';
|
|
4
4
|
import type { OnConfirmSignUp } from './types';
|
|
5
5
|
|
|
6
|
+
export type AuthConfirmSignUpProps = {
|
|
7
|
+
email: string;
|
|
8
|
+
onConfirmSignUp: OnConfirmSignUp;
|
|
9
|
+
};
|
|
10
|
+
|
|
6
11
|
export const AuthConfirmSignUp = ({
|
|
7
12
|
email,
|
|
8
13
|
onConfirmSignUp,
|
|
9
|
-
}: {
|
|
10
|
-
email: string;
|
|
11
|
-
onConfirmSignUp: OnConfirmSignUp;
|
|
12
|
-
}) => {
|
|
14
|
+
}: AuthConfirmSignUpProps) => {
|
|
13
15
|
const { intl } = useI18n();
|
|
14
16
|
|
|
15
17
|
const schema = yup
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { AuthCard } from './AuthCard';
|
|
2
|
+
import { Button, Link, Text } from '@ttoss/ui';
|
|
3
|
+
import { Form, FormFieldInput, useForm, yup, yupResolver } from '@ttoss/forms';
|
|
4
|
+
import { NotificationsBox } from '@ttoss/react-notifications';
|
|
5
|
+
import { useI18n } from '@ttoss/react-i18n';
|
|
6
|
+
|
|
7
|
+
export type AuthRecoveryPasswordProps = {
|
|
8
|
+
onRecoveryPassword: (email: string) => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const AuthRecoveryPassword = ({
|
|
12
|
+
onRecoveryPassword,
|
|
13
|
+
}: AuthRecoveryPasswordProps) => {
|
|
14
|
+
const { intl } = useI18n();
|
|
15
|
+
|
|
16
|
+
const schema = yup
|
|
17
|
+
.object()
|
|
18
|
+
.shape({
|
|
19
|
+
email: yup
|
|
20
|
+
.string()
|
|
21
|
+
.required(
|
|
22
|
+
intl.formatMessage({
|
|
23
|
+
description: 'Required field.',
|
|
24
|
+
defaultMessage: 'Enter your email address',
|
|
25
|
+
})
|
|
26
|
+
)
|
|
27
|
+
.email(
|
|
28
|
+
intl.formatMessage({
|
|
29
|
+
description: 'Please, insert a valid e-mail',
|
|
30
|
+
defaultMessage: 'Please, insert a valid e-mail',
|
|
31
|
+
})
|
|
32
|
+
),
|
|
33
|
+
})
|
|
34
|
+
.required();
|
|
35
|
+
|
|
36
|
+
const formMethods = useForm<yup.TypeOf<typeof schema>>({
|
|
37
|
+
resolver: yupResolver(schema),
|
|
38
|
+
mode: 'onBlur',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Form
|
|
43
|
+
{...formMethods}
|
|
44
|
+
sx={{
|
|
45
|
+
maxWidth: '390px',
|
|
46
|
+
}}
|
|
47
|
+
onSubmit={({ email }) => {
|
|
48
|
+
return onRecoveryPassword(email);
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
<AuthCard
|
|
52
|
+
buttonLabel={intl.formatMessage({
|
|
53
|
+
description: 'Recover Password',
|
|
54
|
+
defaultMessage: 'Recover Password',
|
|
55
|
+
})}
|
|
56
|
+
isValidForm={formMethods.formState.isValid}
|
|
57
|
+
title={intl.formatMessage({
|
|
58
|
+
description: 'Recovering Password',
|
|
59
|
+
defaultMessage: 'Recovering Password',
|
|
60
|
+
})}
|
|
61
|
+
extraButton={
|
|
62
|
+
<Button
|
|
63
|
+
sx={{ textAlign: 'center', display: 'initial' }}
|
|
64
|
+
variant="secondary"
|
|
65
|
+
>
|
|
66
|
+
{intl.formatMessage({
|
|
67
|
+
description: 'Cancel',
|
|
68
|
+
defaultMessage: 'Cancel',
|
|
69
|
+
})}
|
|
70
|
+
</Button>
|
|
71
|
+
}
|
|
72
|
+
>
|
|
73
|
+
<FormFieldInput
|
|
74
|
+
name="email"
|
|
75
|
+
label={intl.formatMessage({
|
|
76
|
+
description: 'Registered Email',
|
|
77
|
+
defaultMessage: 'Registered Email',
|
|
78
|
+
})}
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
<NotificationsBox />
|
|
82
|
+
|
|
83
|
+
<Text sx={{ marginTop: 'xl', cursor: 'pointer' }} as={Link}>
|
|
84
|
+
{intl.formatMessage({
|
|
85
|
+
description: 'Sign up now',
|
|
86
|
+
defaultMessage: 'Sign up now',
|
|
87
|
+
})}
|
|
88
|
+
</Text>
|
|
89
|
+
</AuthCard>
|
|
90
|
+
</Form>
|
|
91
|
+
);
|
|
92
|
+
};
|
package/src/AuthSignIn.tsx
CHANGED
|
@@ -41,13 +41,13 @@ export const AuthSignIn = ({
|
|
|
41
41
|
.required(
|
|
42
42
|
intl.formatMessage({
|
|
43
43
|
description: 'Email is a required field.',
|
|
44
|
-
defaultMessage: '
|
|
44
|
+
defaultMessage: 'Enter your email address',
|
|
45
45
|
})
|
|
46
46
|
)
|
|
47
47
|
.email(
|
|
48
48
|
intl.formatMessage({
|
|
49
49
|
description: 'Invalid email.',
|
|
50
|
-
defaultMessage: '
|
|
50
|
+
defaultMessage: 'Please, insert a valid e-mail',
|
|
51
51
|
})
|
|
52
52
|
),
|
|
53
53
|
password: yup
|
|
@@ -74,6 +74,7 @@ export const AuthSignIn = ({
|
|
|
74
74
|
|
|
75
75
|
const formMethods = useForm<OnSignInInput>({
|
|
76
76
|
defaultValues,
|
|
77
|
+
mode: 'onBlur',
|
|
77
78
|
resolver: yupResolver(schema),
|
|
78
79
|
});
|
|
79
80
|
|
|
@@ -82,7 +83,11 @@ export const AuthSignIn = ({
|
|
|
82
83
|
};
|
|
83
84
|
|
|
84
85
|
return (
|
|
85
|
-
<Form
|
|
86
|
+
<Form
|
|
87
|
+
sx={{ maxWidth: '390px', width: '100%' }}
|
|
88
|
+
{...formMethods}
|
|
89
|
+
onSubmit={onSubmitForm}
|
|
90
|
+
>
|
|
86
91
|
<AuthCard
|
|
87
92
|
title={intl.formatMessage({
|
|
88
93
|
description: 'Sign in title.',
|
|
@@ -135,7 +140,11 @@ export const AuthSignIn = ({
|
|
|
135
140
|
})}
|
|
136
141
|
/> */}
|
|
137
142
|
|
|
138
|
-
<Text
|
|
143
|
+
<Text
|
|
144
|
+
sx={{ marginLeft: 'auto' }}
|
|
145
|
+
as={Link}
|
|
146
|
+
onClick={onForgotPassword}
|
|
147
|
+
>
|
|
139
148
|
{intl.formatMessage({
|
|
140
149
|
description: 'Forgot password?',
|
|
141
150
|
defaultMessage: 'Forgot password?',
|
package/src/AuthSignUp.tsx
CHANGED
|
@@ -33,7 +33,7 @@ export const AuthSignUp = ({ onSignUp, onReturnToSignIn }: AuthSignUpProps) => {
|
|
|
33
33
|
.required(
|
|
34
34
|
intl.formatMessage({
|
|
35
35
|
description: 'Email is a required field.',
|
|
36
|
-
defaultMessage: '
|
|
36
|
+
defaultMessage: 'Enter your email address',
|
|
37
37
|
})
|
|
38
38
|
)
|
|
39
39
|
.email(
|
|
@@ -60,6 +60,13 @@ export const AuthSignUp = ({ onSignUp, onReturnToSignIn }: AuthSignUpProps) => {
|
|
|
60
60
|
{ value: PASSWORD_MINIMUM_LENGTH }
|
|
61
61
|
)
|
|
62
62
|
)
|
|
63
|
+
.oneOf(
|
|
64
|
+
[yup.ref('confirmPassword')],
|
|
65
|
+
intl.formatMessage({
|
|
66
|
+
description: 'Password requirements not met',
|
|
67
|
+
defaultMessage: 'Password requirements not met',
|
|
68
|
+
})
|
|
69
|
+
)
|
|
63
70
|
.trim(),
|
|
64
71
|
confirmPassword: yup
|
|
65
72
|
.string()
|
|
@@ -88,7 +95,11 @@ export const AuthSignUp = ({ onSignUp, onReturnToSignIn }: AuthSignUpProps) => {
|
|
|
88
95
|
};
|
|
89
96
|
|
|
90
97
|
return (
|
|
91
|
-
<Form
|
|
98
|
+
<Form
|
|
99
|
+
sx={{ maxWidth: '390px', width: '100%' }}
|
|
100
|
+
{...formMethods}
|
|
101
|
+
onSubmit={onSubmitForm}
|
|
102
|
+
>
|
|
92
103
|
<AuthCard
|
|
93
104
|
buttonLabel={intl.formatMessage({
|
|
94
105
|
description: 'Create account.',
|
|
@@ -100,7 +111,7 @@ export const AuthSignUp = ({ onSignUp, onReturnToSignIn }: AuthSignUpProps) => {
|
|
|
100
111
|
})}
|
|
101
112
|
isValidForm={formMethods.formState.isValid}
|
|
102
113
|
extraButton={
|
|
103
|
-
<Text onClick={onReturnToSignIn} as={Link}>
|
|
114
|
+
<Text sx={{ cursor: 'pointer' }} onClick={onReturnToSignIn} as={Link}>
|
|
104
115
|
{intl.formatMessage({
|
|
105
116
|
description: 'Link to sign in on sign up.',
|
|
106
117
|
defaultMessage: 'I’m already registered',
|