@jsb188/auth-web 1.1.10 → 1.1.11
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/package.json +25 -25
- package/src/hooks/use-oauth.tsx +341 -311
- package/src/modules/AssignRequiredAuth.tsx +182 -170
- package/src/modules/AuthFormUI.tsx +28 -28
- package/src/modules/AuthForms-SSO.tsx +188 -151
- package/src/modules/AuthForms.tsx +676 -607
- package/src/modules/AuthGate.tsx +108 -85
- package/src/modules/InlineAuthForm.tsx +129 -116
- package/src/modules/ManagedSessions.tsx +109 -83
- package/src/modules/OtherAuthButtons.tsx +73 -71
- package/src/modules/_helpers.ts +102 -84
- package/src/modules/schemas.ts +231 -202
- package/src/schemas/account.ts +153 -138
- package/src/schemas/address.ts +155 -138
- package/src/ui/ManagedSessionUI.tsx +70 -64
|
@@ -1,215 +1,264 @@
|
|
|
1
1
|
import { APP_EMAILS } from '@jsb188/app/constants/app.ts';
|
|
2
2
|
import i18n from '@jsb188/app/i18n/index.ts';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
useCheckUsernameOrEmail,
|
|
5
|
+
useConfirmPhoneVerificationCode,
|
|
6
|
+
useRequestTokenizedEmail,
|
|
7
|
+
useSendPhoneVerificationCode,
|
|
8
|
+
useSignUpWithEmail,
|
|
9
|
+
} from '@jsb188/graphql/hooks/use-auth-mtn';
|
|
4
10
|
import { SMSCodeInput } from '@jsb188/react-web/modules/Form';
|
|
5
11
|
import SchemaForm from '@jsb188/react-web/modules/SchemaForm';
|
|
6
12
|
import { FullWidthButton } from '@jsb188/react-web/ui/Button';
|
|
7
13
|
import { FormBreak } from '@jsb188/react-web/ui/Form';
|
|
8
14
|
import Markdown, { TextWithLinks } from '@jsb188/react-web/ui/Markdown';
|
|
9
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
ModalErrorMessage,
|
|
17
|
+
ModalSimpleContent,
|
|
18
|
+
} from '@jsb188/react-web/ui/ModalUI';
|
|
10
19
|
import { useMemo, useState } from 'react';
|
|
11
20
|
import { Link, useNavigate } from 'react-router';
|
|
12
21
|
import type { AuthPageName } from './_helpers';
|
|
13
22
|
import { getAuthRoute, persistSignInSession } from './_helpers';
|
|
14
23
|
import { SsoSignIn } from './AuthForms-SSO';
|
|
15
|
-
import {
|
|
16
|
-
|
|
24
|
+
import {
|
|
25
|
+
ContinueWithGoogle,
|
|
26
|
+
ContinueWithMicrosoft,
|
|
27
|
+
ContinueWithPhone,
|
|
28
|
+
ContinueWithSso,
|
|
29
|
+
} from './OtherAuthButtons';
|
|
30
|
+
import {
|
|
31
|
+
makeRequestTokenizedEmailSchema,
|
|
32
|
+
makeSendPhoneVerificationSchema,
|
|
33
|
+
makeSignInSchema,
|
|
34
|
+
makeSignUpSchema,
|
|
35
|
+
} from './schemas';
|
|
17
36
|
|
|
18
37
|
/**
|
|
19
38
|
* Page meta tags
|
|
20
39
|
*/
|
|
21
40
|
|
|
22
|
-
export const meta = [
|
|
23
|
-
|
|
24
|
-
}
|
|
41
|
+
export const meta = [
|
|
42
|
+
{
|
|
43
|
+
title: i18n.t('app.route_', { text: i18n.t('app.route_auth') }),
|
|
44
|
+
},
|
|
45
|
+
];
|
|
25
46
|
|
|
26
47
|
/**
|
|
27
48
|
* Sign in form (main screen)
|
|
28
49
|
*/
|
|
29
50
|
|
|
30
51
|
interface AuthFormProps {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
52
|
+
appNamespace: string;
|
|
53
|
+
initialError?: any;
|
|
54
|
+
initialFormData?: any;
|
|
55
|
+
authRoutesMap?: Record<AuthPageName, string>;
|
|
56
|
+
setAuthIface: (iface: SignInIface | null) => void;
|
|
57
|
+
|
|
58
|
+
// Check if needed still
|
|
59
|
+
onError?: (error: any) => void;
|
|
39
60
|
}
|
|
40
61
|
|
|
41
62
|
function SignInMain(p: AuthFormProps) {
|
|
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
|
-
|
|
63
|
+
const { authRoutesMap, initialError, initialFormData, setAuthIface } = p;
|
|
64
|
+
const navigate = useNavigate();
|
|
65
|
+
const [waitingForPostRequest, setWaitingForPostRequest] = useState(false);
|
|
66
|
+
const signInSchema = useMemo(makeSignInSchema, []);
|
|
67
|
+
const {
|
|
68
|
+
saving,
|
|
69
|
+
checkUsernameOrEmail,
|
|
70
|
+
dataForSchema,
|
|
71
|
+
setDataForSchema,
|
|
72
|
+
error,
|
|
73
|
+
setError,
|
|
74
|
+
resetErrors,
|
|
75
|
+
} = useCheckUsernameOrEmail({
|
|
76
|
+
initialError,
|
|
77
|
+
initialFormData,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const hidePassword = dataForSchema.hidePassword;
|
|
81
|
+
const onFormValuesChange = (
|
|
82
|
+
formValues: any,
|
|
83
|
+
_currentValues: any,
|
|
84
|
+
setFormValues: (val: any) => void,
|
|
85
|
+
) => {
|
|
86
|
+
const hasInput = !!formValues.identifier?.trim();
|
|
87
|
+
if (
|
|
88
|
+
!hidePassword &&
|
|
89
|
+
formValues.identifier !== dataForSchema.lastIdentifier
|
|
90
|
+
) {
|
|
91
|
+
setDataForSchema({
|
|
92
|
+
...dataForSchema,
|
|
93
|
+
hasInput,
|
|
94
|
+
lastIdentifier: '',
|
|
95
|
+
hidePassword: true,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
setFormValues({
|
|
99
|
+
...formValues,
|
|
100
|
+
password: '',
|
|
101
|
+
});
|
|
102
|
+
} else if (hasInput !== dataForSchema.hasInput) {
|
|
103
|
+
setDataForSchema({
|
|
104
|
+
...dataForSchema,
|
|
105
|
+
hasInput,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
async function onSubmit(
|
|
111
|
+
formValues: any,
|
|
112
|
+
_currentValues: any,
|
|
113
|
+
setFormValues: any,
|
|
114
|
+
) {
|
|
115
|
+
const identifier = formValues.identifier?.trim();
|
|
116
|
+
if (hidePassword) {
|
|
117
|
+
const { checkUsernameOrEmail: result } = await checkUsernameOrEmail({
|
|
118
|
+
variables: {
|
|
119
|
+
usernameOrEmail: identifier,
|
|
120
|
+
authCheck: true,
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
switch (result?.type) {
|
|
125
|
+
case 'PHONE':
|
|
126
|
+
{
|
|
127
|
+
if (!result.taken) {
|
|
128
|
+
setError({
|
|
129
|
+
message: i18n.t('auth.no_account_with_phone'),
|
|
130
|
+
});
|
|
131
|
+
return false;
|
|
132
|
+
} else if (result?.hasPassword === false) {
|
|
133
|
+
setAuthIface('VERIFY_PHONE');
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
// Do this if you want to redirect to sign up
|
|
137
|
+
// setScreen({
|
|
138
|
+
// name: 'sign_up',
|
|
139
|
+
// email: result.value,
|
|
140
|
+
// });
|
|
141
|
+
// return false;
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
case 'EMAIL':
|
|
145
|
+
{
|
|
146
|
+
if (!result.taken) {
|
|
147
|
+
setError({
|
|
148
|
+
message: i18n.t('auth.no_account_with_email'),
|
|
149
|
+
});
|
|
150
|
+
// Do this if you want to redirect to sign up
|
|
151
|
+
// setScreen({
|
|
152
|
+
// name: 'sign_up',
|
|
153
|
+
// email: result.value,
|
|
154
|
+
// });
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
159
|
+
default:
|
|
160
|
+
// This auth type is not supported
|
|
161
|
+
console.dev('Unknown auth type:', result);
|
|
162
|
+
|
|
163
|
+
if (result?.type) {
|
|
164
|
+
setError({
|
|
165
|
+
message: i18n.t('auth.not_valid_email_or_phone'),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
setDataForSchema({
|
|
172
|
+
...dataForSchema,
|
|
173
|
+
lastIdentifier: identifier || '',
|
|
174
|
+
hidePassword: !result?.taken,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
setFormValues({
|
|
178
|
+
...formValues,
|
|
179
|
+
identifier: identifier || '',
|
|
180
|
+
});
|
|
181
|
+
} else if (formValues.password && identifier) {
|
|
182
|
+
setWaitingForPostRequest(true);
|
|
183
|
+
return true; // "Do" post form
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return false; // Do not post form
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const showSignUpLink = hidePassword && !error;
|
|
190
|
+
|
|
191
|
+
const onFinishSignIn = async (
|
|
192
|
+
token: string,
|
|
193
|
+
sessionBootstrapToken?: string | null,
|
|
194
|
+
sessionPersisted?: boolean,
|
|
195
|
+
) => {
|
|
196
|
+
const persisted =
|
|
197
|
+
sessionPersisted ||
|
|
198
|
+
(await persistSignInSession(token, sessionBootstrapToken));
|
|
199
|
+
if (!persisted) {
|
|
200
|
+
setError({
|
|
201
|
+
message: i18n.t('error.network_error'),
|
|
202
|
+
});
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
navigate(getAuthRoute('signin_success', authRoutesMap));
|
|
206
|
+
return true;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<>
|
|
211
|
+
<ContinueWithGoogle onFinishSignIn={onFinishSignIn} />
|
|
212
|
+
<ContinueWithMicrosoft onFinishSignIn={onFinishSignIn} />
|
|
213
|
+
<ContinueWithSso onClickButton={() => setAuthIface('SSO')} />
|
|
214
|
+
<ContinueWithPhone onClickButton={() => setAuthIface('VERIFY_PHONE')} />
|
|
215
|
+
|
|
216
|
+
<FormBreak className="mt_md" colorClassName="strong_bf">
|
|
217
|
+
{i18n.t('form.or')}
|
|
218
|
+
</FormBreak>
|
|
219
|
+
|
|
220
|
+
<SchemaForm
|
|
221
|
+
doNotPostForm={(fv) => !fv.identifier || !fv.password}
|
|
222
|
+
httpMethod="post"
|
|
223
|
+
actionUrl={getAuthRoute('signin', authRoutesMap)}
|
|
224
|
+
className="py_df"
|
|
225
|
+
currentData={{ identifier: initialFormData?.identifier || '' }}
|
|
226
|
+
saving={saving || waitingForPostRequest}
|
|
227
|
+
schema={signInSchema}
|
|
228
|
+
dataForSchema={dataForSchema}
|
|
229
|
+
onSubmit={onSubmit}
|
|
230
|
+
onFormValuesChange={onFormValuesChange}
|
|
231
|
+
>
|
|
232
|
+
<input type="hidden" name="managedSessionVersion" value="1" />
|
|
233
|
+
{error && (
|
|
234
|
+
<ModalErrorMessage
|
|
235
|
+
error={error}
|
|
236
|
+
resetErrors={resetErrors}
|
|
237
|
+
// className='mt_sm'
|
|
238
|
+
/>
|
|
239
|
+
)}
|
|
240
|
+
</SchemaForm>
|
|
241
|
+
|
|
242
|
+
<div className="a_c">
|
|
243
|
+
{showSignUpLink ? (
|
|
244
|
+
<Link
|
|
245
|
+
className="text ft_sm cl_md link"
|
|
246
|
+
to={getAuthRoute('signup', authRoutesMap)}
|
|
247
|
+
replace
|
|
248
|
+
>
|
|
249
|
+
{i18n.t('auth.signup_email')}
|
|
250
|
+
</Link>
|
|
251
|
+
) : (
|
|
252
|
+
<button
|
|
253
|
+
className="text ft_sm cl_md link"
|
|
254
|
+
onClick={() => setAuthIface('REQUEST_PASSWORD_RESET')}
|
|
255
|
+
>
|
|
256
|
+
{i18n.t('auth.forgot_password_')}
|
|
257
|
+
</button>
|
|
258
|
+
)}
|
|
259
|
+
</div>
|
|
260
|
+
</>
|
|
261
|
+
);
|
|
213
262
|
}
|
|
214
263
|
|
|
215
264
|
/**
|
|
@@ -217,94 +266,91 @@ function SignInMain(p: AuthFormProps) {
|
|
|
217
266
|
*/
|
|
218
267
|
|
|
219
268
|
interface RequestTokenizedEmailProps extends AuthFormProps {
|
|
220
|
-
|
|
269
|
+
requestType: 'PASSWORD_RESET' | 'EMAIL_VERIFICATION';
|
|
221
270
|
}
|
|
222
271
|
|
|
223
272
|
function RequestTokenizedEmail(p: RequestTokenizedEmailProps) {
|
|
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
|
-
</Markdown>
|
|
306
|
-
</SchemaForm>
|
|
307
|
-
);
|
|
273
|
+
const { requestType, initialFormData, setAuthIface } = p;
|
|
274
|
+
const [error, setError] = useState<any>(null);
|
|
275
|
+
const initialEmailAddress = initialFormData?.identifier || '';
|
|
276
|
+
const onSuccess = (_emailAddress: string) => setAuthIface('EMAIL_SENT');
|
|
277
|
+
|
|
278
|
+
const tokenizedEmailSchema = useMemo(() => {
|
|
279
|
+
const schema = makeRequestTokenizedEmailSchema();
|
|
280
|
+
if (!initialEmailAddress) {
|
|
281
|
+
return schema;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return {
|
|
285
|
+
...schema,
|
|
286
|
+
listData: schema.listData.map((obj) => {
|
|
287
|
+
if (obj.item.name === 'email') {
|
|
288
|
+
return {
|
|
289
|
+
...obj,
|
|
290
|
+
item: {
|
|
291
|
+
...obj.item,
|
|
292
|
+
placeholder: initialEmailAddress,
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return obj;
|
|
298
|
+
}),
|
|
299
|
+
};
|
|
300
|
+
}, []);
|
|
301
|
+
|
|
302
|
+
// Data hook
|
|
303
|
+
|
|
304
|
+
const { requestTokenizedEmail, saving } = useRequestTokenizedEmail({
|
|
305
|
+
onCompleted: (data: any, _: any, variables: any) => {
|
|
306
|
+
const success = data?.requestTokenizedEmail;
|
|
307
|
+
if (success) {
|
|
308
|
+
onSuccess(variables.email);
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
onError: (err: any) => {
|
|
312
|
+
setError(err);
|
|
313
|
+
},
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
const onSubmit = (fv: any) => {
|
|
317
|
+
requestTokenizedEmail({
|
|
318
|
+
variables: {
|
|
319
|
+
...fv,
|
|
320
|
+
requestType,
|
|
321
|
+
},
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
let instructionText;
|
|
326
|
+
switch (requestType) {
|
|
327
|
+
case 'PASSWORD_RESET':
|
|
328
|
+
instructionText = i18n.t('auth.request_reset_password_instr');
|
|
329
|
+
break;
|
|
330
|
+
case 'EMAIL_VERIFICATION':
|
|
331
|
+
instructionText = i18n.t('auth.resend_verification_instr');
|
|
332
|
+
break;
|
|
333
|
+
default:
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return (
|
|
337
|
+
<SchemaForm
|
|
338
|
+
saving={saving}
|
|
339
|
+
schema={tokenizedEmailSchema}
|
|
340
|
+
currentData={{ email: initialEmailAddress || '' }}
|
|
341
|
+
onError={setError}
|
|
342
|
+
onSubmit={onSubmit}
|
|
343
|
+
buttonText={i18n.t('auth.resend_verification')}
|
|
344
|
+
>
|
|
345
|
+
{!error ? null : (
|
|
346
|
+
<ModalErrorMessage error={error} resetErrors={() => setError(null)} />
|
|
347
|
+
)}
|
|
348
|
+
|
|
349
|
+
<Markdown as="p" className={error ? 'py_xs a_c' : '-mt_5 pb_xs a_c'}>
|
|
350
|
+
{instructionText}
|
|
351
|
+
</Markdown>
|
|
352
|
+
</SchemaForm>
|
|
353
|
+
);
|
|
308
354
|
}
|
|
309
355
|
|
|
310
356
|
/**
|
|
@@ -312,27 +358,31 @@ function RequestTokenizedEmail(p: RequestTokenizedEmailProps) {
|
|
|
312
358
|
*/
|
|
313
359
|
|
|
314
360
|
function ResetPasswordCompleted(p: AuthFormProps) {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
361
|
+
const { initialFormData } = p;
|
|
362
|
+
const emailAddress = initialFormData?.identifier;
|
|
363
|
+
const supportEmail = APP_EMAILS.support;
|
|
364
|
+
|
|
365
|
+
// Because this screen is opened by a client-side fetch, emailAddress will not always be present;
|
|
366
|
+
// Only way to have the used email address here is if we used POST form request.
|
|
367
|
+
|
|
368
|
+
return (
|
|
369
|
+
<ModalSimpleContent
|
|
370
|
+
title={i18n.t('auth.email_sent')}
|
|
371
|
+
iconName="circle-check"
|
|
372
|
+
>
|
|
373
|
+
<TextWithLinks as="p">
|
|
374
|
+
{i18n.t(
|
|
375
|
+
emailAddress
|
|
376
|
+
? 'auth.reset_password_requested_msg'
|
|
377
|
+
: 'auth.reset_password_requested_msg_no_email',
|
|
378
|
+
{ emailAddress },
|
|
379
|
+
)}
|
|
380
|
+
</TextWithLinks>
|
|
381
|
+
<TextWithLinks as="p">
|
|
382
|
+
{i18n.t('auth.if_need_more_help_email', { emailAddress: supportEmail })}
|
|
383
|
+
</TextWithLinks>
|
|
384
|
+
</ModalSimpleContent>
|
|
385
|
+
);
|
|
336
386
|
}
|
|
337
387
|
|
|
338
388
|
/**
|
|
@@ -340,62 +390,65 @@ function ResetPasswordCompleted(p: AuthFormProps) {
|
|
|
340
390
|
*/
|
|
341
391
|
|
|
342
392
|
function SendPhoneVerification(p: AuthFormProps) {
|
|
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
|
-
|
|
393
|
+
const { setAuthIface } = p;
|
|
394
|
+
const sendPhoneVerificationSchema = useMemo(
|
|
395
|
+
() => makeSendPhoneVerificationSchema(),
|
|
396
|
+
[],
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
// Data hook
|
|
400
|
+
|
|
401
|
+
const { sendPhoneVerificationCode, saving, error, setError, resetErrors } =
|
|
402
|
+
useSendPhoneVerificationCode({
|
|
403
|
+
onCompleted: (data: any, _: any, variables: any) => {
|
|
404
|
+
const success = data?.sendPhoneVerificationCode;
|
|
405
|
+
if (success) {
|
|
406
|
+
setAuthIface(['VERIFY_PHONE_SENT', variables.phone]);
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
onError: (err: any) => {
|
|
410
|
+
setError(err);
|
|
411
|
+
},
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
const onSubmit = (fv: any) => {
|
|
415
|
+
sendPhoneVerificationCode({
|
|
416
|
+
variables: {
|
|
417
|
+
phone: fv.phone,
|
|
418
|
+
},
|
|
419
|
+
});
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
return (
|
|
423
|
+
<>
|
|
424
|
+
<SchemaForm
|
|
425
|
+
className="mb_df"
|
|
426
|
+
saving={saving}
|
|
427
|
+
schema={sendPhoneVerificationSchema}
|
|
428
|
+
onError={setError}
|
|
429
|
+
onSubmit={onSubmit}
|
|
430
|
+
buttonText={i18n.t('auth.send_verification_code')}
|
|
431
|
+
>
|
|
432
|
+
{!error ? null : (
|
|
433
|
+
<ModalErrorMessage error={error} resetErrors={resetErrors} />
|
|
434
|
+
)}
|
|
435
|
+
|
|
436
|
+
<p className={error ? 'py_xs a_c' : '-mt_5 pb_xs a_c'}>
|
|
437
|
+
{i18n.t('auth.send_verification_code_msg')}
|
|
438
|
+
</p>
|
|
439
|
+
</SchemaForm>
|
|
440
|
+
|
|
441
|
+
<div className="a_c h_center">
|
|
442
|
+
<button
|
|
443
|
+
disabled={saving}
|
|
444
|
+
onClick={() => setAuthIface(null)}
|
|
445
|
+
className="text ft_sm cl_md link"
|
|
446
|
+
>
|
|
447
|
+
{i18n.t('auth.sign_in_other_methods')}
|
|
448
|
+
</button>
|
|
449
|
+
</div>
|
|
450
|
+
</>
|
|
451
|
+
);
|
|
399
452
|
}
|
|
400
453
|
|
|
401
454
|
/**
|
|
@@ -403,133 +456,141 @@ function SendPhoneVerification(p: AuthFormProps) {
|
|
|
403
456
|
*/
|
|
404
457
|
|
|
405
458
|
interface ConfirmPhoneVerificationCodeProps extends AuthFormProps {
|
|
406
|
-
|
|
459
|
+
phoneNumber: string;
|
|
407
460
|
}
|
|
408
461
|
|
|
409
462
|
function ConfirmPhoneVerificationCode(p: ConfirmPhoneVerificationCodeProps) {
|
|
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
|
-
|
|
463
|
+
const { setAuthIface, phoneNumber, authRoutesMap } = p;
|
|
464
|
+
const [retryCount, setRetryCount] = useState(0);
|
|
465
|
+
const navigate = useNavigate();
|
|
466
|
+
|
|
467
|
+
// Data hook
|
|
468
|
+
|
|
469
|
+
const { confirmPhoneVerificationCode, saving, error, setError, resetErrors } =
|
|
470
|
+
useConfirmPhoneVerificationCode({
|
|
471
|
+
onCompleted: async (data: any, _: any) => {
|
|
472
|
+
const { success, token } = data?.confirmPhoneVerificationCode || {};
|
|
473
|
+
|
|
474
|
+
if (success && token) {
|
|
475
|
+
const persisted = await persistSignInSession(token);
|
|
476
|
+
if (!persisted) {
|
|
477
|
+
setError({
|
|
478
|
+
message: i18n.t('error.network_error'),
|
|
479
|
+
});
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
navigate(getAuthRoute('signin_success', authRoutesMap));
|
|
483
|
+
} else {
|
|
484
|
+
setRetryCount(retryCount + 1);
|
|
485
|
+
setError({
|
|
486
|
+
message: i18n.t('auth.verification_code_wrong'),
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
const onSubmit = (code: string) => {
|
|
493
|
+
confirmPhoneVerificationCode({
|
|
494
|
+
variables: {
|
|
495
|
+
phone: phoneNumber,
|
|
496
|
+
code,
|
|
497
|
+
},
|
|
498
|
+
});
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
return (
|
|
502
|
+
<>
|
|
503
|
+
{!error ? null : (
|
|
504
|
+
<ModalErrorMessage error={error} resetErrors={resetErrors} />
|
|
505
|
+
)}
|
|
506
|
+
<SMSCodeInput
|
|
507
|
+
key={retryCount}
|
|
508
|
+
saving={saving}
|
|
509
|
+
error={error}
|
|
510
|
+
onSubmit={onSubmit}
|
|
511
|
+
/>
|
|
512
|
+
<p className="a_c p_n mt_md mb_df rel">
|
|
513
|
+
{i18n.t('auth.confirm_verification_code_instr')}
|
|
514
|
+
</p>
|
|
515
|
+
<div className="a_c h_center">
|
|
516
|
+
<button
|
|
517
|
+
disabled={saving}
|
|
518
|
+
onClick={() => setAuthIface('VERIFY_PHONE')}
|
|
519
|
+
className="text ft_sm cl_md link"
|
|
520
|
+
>
|
|
521
|
+
{i18n.t('auth.resend_verification_code')}
|
|
522
|
+
</button>
|
|
523
|
+
</div>
|
|
524
|
+
</>
|
|
525
|
+
);
|
|
473
526
|
}
|
|
474
527
|
|
|
475
528
|
/**
|
|
476
529
|
* Sign in form
|
|
477
530
|
*/
|
|
478
531
|
|
|
479
|
-
type SignInIface =
|
|
532
|
+
type SignInIface =
|
|
533
|
+
| 'REQUEST_PASSWORD_RESET'
|
|
534
|
+
| 'SSO'
|
|
535
|
+
| 'VERIFY_PHONE'
|
|
536
|
+
| 'VERIFY_EMAIL'
|
|
537
|
+
| 'EMAIL_SENT'
|
|
538
|
+
| 'VERIFY_PHONE_SENT'
|
|
539
|
+
| ['VERIFY_PHONE_SENT', string];
|
|
480
540
|
|
|
481
541
|
export function SignInForm(p: Omit<AuthFormProps, 'setAuthIface'>) {
|
|
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
|
-
|
|
542
|
+
const { initialError } = p;
|
|
543
|
+
const errCode = initialError?.errorCode;
|
|
544
|
+
const initialIface =
|
|
545
|
+
errCode === '20053'
|
|
546
|
+
? 'VERIFY_PHONE'
|
|
547
|
+
: errCode === '20049'
|
|
548
|
+
? 'VERIFY_EMAIL'
|
|
549
|
+
: null;
|
|
550
|
+
const [signInIface_, setAuthIface] = useState<SignInIface | null>(
|
|
551
|
+
initialIface,
|
|
552
|
+
);
|
|
553
|
+
const ifaceIsArray = Array.isArray(signInIface_);
|
|
554
|
+
|
|
555
|
+
switch (ifaceIsArray ? signInIface_[0] : signInIface_) {
|
|
556
|
+
case 'SSO':
|
|
557
|
+
// Email-first SSO sign in (org home realm discovery)
|
|
558
|
+
return <SsoSignIn {...p} setAuthIface={setAuthIface} />;
|
|
559
|
+
case 'VERIFY_PHONE':
|
|
560
|
+
// Attempted phone login but it was not verified
|
|
561
|
+
return <SendPhoneVerification {...p} setAuthIface={setAuthIface} />;
|
|
562
|
+
case 'VERIFY_PHONE_SENT':
|
|
563
|
+
// User requested phone verification code, and it was sent
|
|
564
|
+
return (
|
|
565
|
+
<ConfirmPhoneVerificationCode
|
|
566
|
+
{...p}
|
|
567
|
+
phoneNumber={ifaceIsArray ? signInIface_[1] : ''}
|
|
568
|
+
setAuthIface={setAuthIface}
|
|
569
|
+
/>
|
|
570
|
+
);
|
|
571
|
+
case 'VERIFY_EMAIL':
|
|
572
|
+
// Attempted email login but it was not verified
|
|
573
|
+
return (
|
|
574
|
+
<RequestTokenizedEmail
|
|
575
|
+
{...p}
|
|
576
|
+
requestType="EMAIL_VERIFICATION"
|
|
577
|
+
setAuthIface={setAuthIface}
|
|
578
|
+
/>
|
|
579
|
+
);
|
|
580
|
+
case 'REQUEST_PASSWORD_RESET':
|
|
581
|
+
return (
|
|
582
|
+
<RequestTokenizedEmail
|
|
583
|
+
{...p}
|
|
584
|
+
requestType="PASSWORD_RESET"
|
|
585
|
+
setAuthIface={setAuthIface}
|
|
586
|
+
/>
|
|
587
|
+
);
|
|
588
|
+
case 'EMAIL_SENT':
|
|
589
|
+
return <ResetPasswordCompleted {...p} setAuthIface={setAuthIface} />;
|
|
590
|
+
default:
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
return <SignInMain {...p} setAuthIface={setAuthIface} />;
|
|
533
594
|
}
|
|
534
595
|
|
|
535
596
|
/**
|
|
@@ -537,100 +598,107 @@ export function SignInForm(p: Omit<AuthFormProps, 'setAuthIface'>) {
|
|
|
537
598
|
*/
|
|
538
599
|
|
|
539
600
|
interface SignUpMainProps extends Omit<AuthFormProps, 'setAuthIface'> {
|
|
540
|
-
|
|
541
|
-
|
|
601
|
+
setAuthIface: (iface: SignUpIface) => void;
|
|
602
|
+
setSignUpToken: (token: string | null) => void;
|
|
542
603
|
}
|
|
543
604
|
|
|
544
605
|
function SignUpMain(p: SignUpMainProps) {
|
|
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
|
-
|
|
606
|
+
const { authRoutesMap, initialError, setAuthIface, setSignUpToken } = p;
|
|
607
|
+
const navigate = useNavigate();
|
|
608
|
+
const signUpSchema = useMemo(makeSignUpSchema, []);
|
|
609
|
+
|
|
610
|
+
const { saving, signUpWithEmail, error, setError, resetErrors } =
|
|
611
|
+
useSignUpWithEmail({
|
|
612
|
+
initialError,
|
|
613
|
+
onCompleted: (data: any, _: any) => {
|
|
614
|
+
const signUpToken = data?.signUpWithEmail;
|
|
615
|
+
|
|
616
|
+
if (signUpToken) {
|
|
617
|
+
setSignUpToken(signUpToken);
|
|
618
|
+
}
|
|
619
|
+
},
|
|
620
|
+
onError: (err: any) => {
|
|
621
|
+
if (err?.errorCode === '20054') {
|
|
622
|
+
setAuthIface('INVITATION_REQUIRED');
|
|
623
|
+
}
|
|
624
|
+
},
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
const onSubmit = async (formValues: any) => {
|
|
628
|
+
signUpWithEmail({
|
|
629
|
+
variables: {
|
|
630
|
+
emailAddress: formValues.email,
|
|
631
|
+
password: formValues.password,
|
|
632
|
+
},
|
|
633
|
+
});
|
|
634
|
+
};
|
|
635
|
+
|
|
636
|
+
// SSO providers auto-create accounts, so they work as sign up too
|
|
637
|
+
const onFinishSignIn = async (
|
|
638
|
+
token: string,
|
|
639
|
+
sessionBootstrapToken?: string | null,
|
|
640
|
+
sessionPersisted?: boolean,
|
|
641
|
+
) => {
|
|
642
|
+
const persisted =
|
|
643
|
+
sessionPersisted ||
|
|
644
|
+
(await persistSignInSession(token, sessionBootstrapToken));
|
|
645
|
+
if (!persisted) {
|
|
646
|
+
setError({
|
|
647
|
+
message: i18n.t('error.network_error'),
|
|
648
|
+
});
|
|
649
|
+
return false;
|
|
650
|
+
}
|
|
651
|
+
navigate(getAuthRoute('signin_success', authRoutesMap));
|
|
652
|
+
return true;
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
return (
|
|
656
|
+
<>
|
|
657
|
+
<ContinueWithGoogle onFinishSignIn={onFinishSignIn} />
|
|
658
|
+
<ContinueWithMicrosoft onFinishSignIn={onFinishSignIn} />
|
|
659
|
+
|
|
660
|
+
<FormBreak className="mt_md" colorClassName="strong_bf">
|
|
661
|
+
{i18n.t('form.or')}
|
|
662
|
+
</FormBreak>
|
|
663
|
+
|
|
664
|
+
<SchemaForm
|
|
665
|
+
className="py_df"
|
|
666
|
+
saving={saving}
|
|
667
|
+
schema={signUpSchema}
|
|
668
|
+
// currentData={{}}
|
|
669
|
+
onError={setError}
|
|
670
|
+
onSubmit={onSubmit}
|
|
671
|
+
buttonText={i18n.t('auth.agree_and_continue')}
|
|
672
|
+
FooterComponent={
|
|
673
|
+
<TextWithLinks
|
|
674
|
+
as="div"
|
|
675
|
+
className="ft_xs mt_sm cl_md"
|
|
676
|
+
linkClassName="u link cl_md"
|
|
677
|
+
>
|
|
678
|
+
{i18n.t('auth.sign_up_notice_msg')}
|
|
679
|
+
</TextWithLinks>
|
|
680
|
+
}
|
|
681
|
+
>
|
|
682
|
+
{!error ? null : (
|
|
683
|
+
<ModalErrorMessage
|
|
684
|
+
error={error}
|
|
685
|
+
resetErrors={resetErrors}
|
|
686
|
+
// className='mt_sm'
|
|
687
|
+
/>
|
|
688
|
+
)}
|
|
689
|
+
</SchemaForm>
|
|
690
|
+
|
|
691
|
+
<div className="a_c h_center">
|
|
692
|
+
<Link
|
|
693
|
+
to={getAuthRoute('signin', authRoutesMap)}
|
|
694
|
+
replace
|
|
695
|
+
className="text ft_sm cl_md link"
|
|
696
|
+
>
|
|
697
|
+
{i18n.t('auth.sign_in_w_existing')}
|
|
698
|
+
</Link>
|
|
699
|
+
</div>
|
|
700
|
+
</>
|
|
701
|
+
);
|
|
634
702
|
}
|
|
635
703
|
|
|
636
704
|
/**
|
|
@@ -638,16 +706,18 @@ function SignUpMain(p: SignUpMainProps) {
|
|
|
638
706
|
*/
|
|
639
707
|
|
|
640
708
|
function SignUpInviteRequired(p: Omit<AuthFormProps, 'setAuthIface'>) {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
709
|
+
const supportEmail = APP_EMAILS.support;
|
|
710
|
+
|
|
711
|
+
return (
|
|
712
|
+
<ModalSimpleContent
|
|
713
|
+
title={i18n.t('auth.invite_required')}
|
|
714
|
+
iconName="mailbox-filled"
|
|
715
|
+
>
|
|
716
|
+
<TextWithLinks as="p">
|
|
717
|
+
{i18n.t('auth.invite_required_msg', { emailAddress: supportEmail })}
|
|
718
|
+
</TextWithLinks>
|
|
719
|
+
</ModalSimpleContent>
|
|
720
|
+
);
|
|
651
721
|
}
|
|
652
722
|
|
|
653
723
|
/**
|
|
@@ -655,30 +725,30 @@ function SignUpInviteRequired(p: Omit<AuthFormProps, 'setAuthIface'>) {
|
|
|
655
725
|
*/
|
|
656
726
|
|
|
657
727
|
interface SignUpSuccessProps extends Omit<AuthFormProps, 'setAuthIface'> {
|
|
658
|
-
|
|
728
|
+
signUpToken: string;
|
|
659
729
|
}
|
|
660
730
|
|
|
661
731
|
function SignUpSuccess(p: SignUpSuccessProps) {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
732
|
+
const { authRoutesMap } = p;
|
|
733
|
+
|
|
734
|
+
return (
|
|
735
|
+
<ModalSimpleContent
|
|
736
|
+
title={i18n.t('auth.account_created')}
|
|
737
|
+
iconName="circle-check"
|
|
738
|
+
className="px_df pt_md"
|
|
739
|
+
>
|
|
740
|
+
<TextWithLinks as="p">{i18n.t('auth.account_created_msg')}</TextWithLinks>
|
|
741
|
+
|
|
742
|
+
<FullWidthButton
|
|
743
|
+
to={getAuthRoute('signin', authRoutesMap)}
|
|
744
|
+
preset="bg_primary"
|
|
745
|
+
className="mt_lg shadow"
|
|
746
|
+
replace
|
|
747
|
+
>
|
|
748
|
+
{i18n.t('auth.continue_to_login')}
|
|
749
|
+
</FullWidthButton>
|
|
750
|
+
</ModalSimpleContent>
|
|
751
|
+
);
|
|
682
752
|
}
|
|
683
753
|
|
|
684
754
|
/**
|
|
@@ -688,25 +758,24 @@ function SignUpSuccess(p: SignUpSuccessProps) {
|
|
|
688
758
|
type SignUpIface = 'INVITATION_REQUIRED' | null;
|
|
689
759
|
|
|
690
760
|
export function SignUpForm(p: Omit<AuthFormProps, 'setAuthIface'>) {
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
/>;
|
|
761
|
+
const [signUpToken, setSignUpToken] = useState<string | null>(null);
|
|
762
|
+
const [signUpIface, setAuthIface] = useState<SignUpIface>(null);
|
|
763
|
+
|
|
764
|
+
if (signUpToken) {
|
|
765
|
+
return <SignUpSuccess {...p} signUpToken={signUpToken} />;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
switch (signUpIface) {
|
|
769
|
+
case 'INVITATION_REQUIRED':
|
|
770
|
+
return <SignUpInviteRequired {...p} />;
|
|
771
|
+
default:
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
return (
|
|
775
|
+
<SignUpMain
|
|
776
|
+
{...p}
|
|
777
|
+
setAuthIface={setAuthIface}
|
|
778
|
+
setSignUpToken={setSignUpToken}
|
|
779
|
+
/>
|
|
780
|
+
);
|
|
712
781
|
}
|