@jsb188/auth-web 1.1.11 → 1.1.12
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 +9 -7
- package/src/hooks/use-auth-popup.ts +167 -0
- package/src/hooks/use-google-one-tap.ts +138 -0
- package/src/hooks/use-oauth.tsx +25 -51
- package/src/main.ts +11 -0
- package/src/modules/AssignRequiredAuth.tsx +93 -59
- package/src/modules/AuthFormUI.tsx +2 -2
- package/src/modules/AuthForms-SSO.tsx +43 -58
- package/src/modules/AuthForms.tsx +420 -287
- package/src/modules/AuthGate.tsx +8 -23
- package/src/modules/ConfirmPublicFormEmailCode.tsx +144 -0
- package/src/modules/InlineAuthForm.tsx +373 -75
- package/src/modules/ManagedSessions.tsx +22 -42
- package/src/modules/OtherAuthButtons.tsx +9 -7
- package/src/modules/_helpers.ts +94 -37
- package/src/modules/schemas.ts +114 -244
- package/src/schemas/account.ts +86 -149
- package/src/schemas/address.ts +108 -157
- package/src/utils/authPopup.ts +95 -0
- package/src/utils/googleIdentity.ts +100 -0
|
@@ -1,33 +1,32 @@
|
|
|
1
1
|
import { APP_EMAILS } from '@jsb188/app/constants/app.ts';
|
|
2
2
|
import i18n from '@jsb188/app/i18n/index.ts';
|
|
3
3
|
import {
|
|
4
|
+
useAuthenticateAsAgent,
|
|
4
5
|
useCheckUsernameOrEmail,
|
|
5
6
|
useConfirmPhoneVerificationCode,
|
|
6
7
|
useRequestTokenizedEmail,
|
|
7
8
|
useSendPhoneVerificationCode,
|
|
8
9
|
useSignUpWithEmail,
|
|
9
10
|
} from '@jsb188/graphql/hooks/use-auth-mtn';
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
11
|
+
import { useSendPublicFormEmailCode } from '@jsb188/graphql/hooks/use-publicFormEmail-mtn';
|
|
12
|
+
import { SMSCodeInput } from '@jsb188/form/modules/Form';
|
|
13
|
+
import SchemaForm from '@jsb188/form/libs/SchemaForm';
|
|
14
|
+
import { submissionResult } from '@jsb188/form/libs/validation';
|
|
15
|
+
import type { FormActions, SubmitResult } from '@jsb188/form/libs/SchemaForm.types';
|
|
12
16
|
import { FullWidthButton } from '@jsb188/react-web/ui/Button';
|
|
13
|
-
import { FormBreak } from '@jsb188/
|
|
17
|
+
import { FormBreak } from '@jsb188/form/ui/Form';
|
|
14
18
|
import Markdown, { TextWithLinks } from '@jsb188/react-web/ui/Markdown';
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
ModalSimpleContent,
|
|
18
|
-
} from '@jsb188/react-web/ui/ModalUI';
|
|
19
|
-
import { useMemo, useState } from 'react';
|
|
19
|
+
import { ModalErrorMessage, ModalSimpleContent } from '@jsb188/react-web/ui/ModalUI';
|
|
20
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
20
21
|
import { Link, useNavigate } from 'react-router';
|
|
22
|
+
import { getAuthPopupCompletionPath } from '../utils/authPopup.ts';
|
|
21
23
|
import type { AuthPageName } from './_helpers';
|
|
22
|
-
import { getAuthRoute, persistSignInSession } from './_helpers';
|
|
24
|
+
import { getAuthReturnQuery, getAuthRoute, persistSignInSession } from './_helpers';
|
|
23
25
|
import { SsoSignIn } from './AuthForms-SSO';
|
|
26
|
+
import { ConfirmPublicFormEmailCode } from './ConfirmPublicFormEmailCode';
|
|
27
|
+
import { ContinueWithGoogle, ContinueWithMicrosoft, ContinueWithPhone, ContinueWithSso } from './OtherAuthButtons';
|
|
24
28
|
import {
|
|
25
|
-
|
|
26
|
-
ContinueWithMicrosoft,
|
|
27
|
-
ContinueWithPhone,
|
|
28
|
-
ContinueWithSso,
|
|
29
|
-
} from './OtherAuthButtons';
|
|
30
|
-
import {
|
|
29
|
+
type SignInFormValues,
|
|
31
30
|
makeRequestTokenizedEmailSchema,
|
|
32
31
|
makeSendPhoneVerificationSchema,
|
|
33
32
|
makeSignInSchema,
|
|
@@ -50,44 +49,83 @@ export const meta = [
|
|
|
50
49
|
|
|
51
50
|
interface AuthFormProps {
|
|
52
51
|
appNamespace: string;
|
|
52
|
+
formPublicId?: string | null;
|
|
53
|
+
allowPublicFormEmail?: boolean;
|
|
54
|
+
onPublicFormRespondentVerified?: (token: string, email: string | null) => boolean;
|
|
55
|
+
initialMethod?: 'PHONE';
|
|
53
56
|
initialError?: any;
|
|
54
57
|
initialFormData?: any;
|
|
55
58
|
authRoutesMap?: Record<AuthPageName, string>;
|
|
59
|
+
popupId?: string | null;
|
|
60
|
+
popupMode?: boolean;
|
|
61
|
+
returnTo?: string | null;
|
|
62
|
+
// Development-only: when true, show the password-less "AI agents Enter"
|
|
63
|
+
// button. Provided by the host app's sign-in loader; the server reports it
|
|
64
|
+
// as true only on a local development database.
|
|
65
|
+
agentLoginAvailable?: boolean;
|
|
56
66
|
setAuthIface: (iface: SignInIface | null) => void;
|
|
57
67
|
|
|
58
68
|
// Check if needed still
|
|
59
69
|
onError?: (error: any) => void;
|
|
60
70
|
}
|
|
61
71
|
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
/*
|
|
73
|
+
* Preserve public-form and popup context across one authentication navigation.
|
|
74
|
+
*/
|
|
75
|
+
function getAuthNavigationQuery(returnTo?: string | null, popupMode?: boolean, popupId?: string | null) {
|
|
76
|
+
const searchParams = new URLSearchParams(getAuthReturnQuery(returnTo));
|
|
77
|
+
if (popupMode && popupId) {
|
|
78
|
+
searchParams.set('popup', '1');
|
|
79
|
+
searchParams.set('popupId', popupId);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return searchParams.toString() || undefined;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/*
|
|
86
|
+
* Return the popup handoff route or the standard post-authentication route.
|
|
87
|
+
*/
|
|
88
|
+
function getSignInSuccessRoute(p: Pick<AuthFormProps, 'authRoutesMap' | 'popupId' | 'popupMode' | 'returnTo'>) {
|
|
89
|
+
const popupCompletionPath = p.popupMode ? getAuthPopupCompletionPath(p.popupId) : null;
|
|
90
|
+
if (popupCompletionPath) {
|
|
91
|
+
return popupCompletionPath;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return getAuthRoute('signin_success', p.authRoutesMap, getAuthReturnQuery(p.returnTo));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/*
|
|
98
|
+
* Discover existing accounts or send one public-form email code before choosing the verification screen.
|
|
99
|
+
*/
|
|
100
|
+
const SignInMain = (p: AuthFormProps) => {
|
|
101
|
+
const { authRoutesMap, formPublicId, initialError, initialFormData, popupId, popupMode, returnTo, setAuthIface } = p;
|
|
64
102
|
const navigate = useNavigate();
|
|
65
103
|
const [waitingForPostRequest, setWaitingForPostRequest] = useState(false);
|
|
104
|
+
const mounted = useRef(true);
|
|
66
105
|
const signInSchema = useMemo(makeSignInSchema, []);
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
dataForSchema,
|
|
71
|
-
setDataForSchema,
|
|
72
|
-
error,
|
|
73
|
-
setError,
|
|
74
|
-
resetErrors,
|
|
75
|
-
} = useCheckUsernameOrEmail({
|
|
106
|
+
const allowPublicFormEmail = !!p.allowPublicFormEmail && !!formPublicId && !!p.onPublicFormRespondentVerified;
|
|
107
|
+
const { sendPublicFormEmailCode, saving: sendingEmailCode } = useSendPublicFormEmailCode();
|
|
108
|
+
const { saving, checkUsernameOrEmail, dataForSchema, setDataForSchema, error, setError, resetErrors } = useCheckUsernameOrEmail({
|
|
76
109
|
initialError,
|
|
77
|
-
initialFormData
|
|
110
|
+
initialFormData: {
|
|
111
|
+
...initialFormData,
|
|
112
|
+
usernameOrEmail: initialFormData?.identifier || initialFormData?.usernameOrEmail || '',
|
|
113
|
+
},
|
|
78
114
|
});
|
|
79
115
|
|
|
80
116
|
const hidePassword = dataForSchema.hidePassword;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
117
|
+
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
mounted.current = true;
|
|
120
|
+
return () => {
|
|
121
|
+
mounted.current = false;
|
|
122
|
+
};
|
|
123
|
+
}, []);
|
|
124
|
+
|
|
125
|
+
/* Return to identifier discovery when the previously resolved identifier changes. */
|
|
126
|
+
const onFormValuesChange = (formValues: SignInFormValues, { setValues }: FormActions<SignInFormValues>) => {
|
|
86
127
|
const hasInput = !!formValues.identifier?.trim();
|
|
87
|
-
if (
|
|
88
|
-
!hidePassword &&
|
|
89
|
-
formValues.identifier !== dataForSchema.lastIdentifier
|
|
90
|
-
) {
|
|
128
|
+
if (!hidePassword && formValues.identifier !== dataForSchema.lastIdentifier) {
|
|
91
129
|
setDataForSchema({
|
|
92
130
|
...dataForSchema,
|
|
93
131
|
hasInput,
|
|
@@ -95,7 +133,7 @@ function SignInMain(p: AuthFormProps) {
|
|
|
95
133
|
hidePassword: true,
|
|
96
134
|
});
|
|
97
135
|
|
|
98
|
-
|
|
136
|
+
setValues({
|
|
99
137
|
...formValues,
|
|
100
138
|
password: '',
|
|
101
139
|
});
|
|
@@ -107,129 +145,182 @@ function SignInMain(p: AuthFormProps) {
|
|
|
107
145
|
}
|
|
108
146
|
};
|
|
109
147
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
) {
|
|
115
|
-
const identifier = formValues.identifier
|
|
148
|
+
/* Resolve the account before authorizing the native password-manager-compatible form POST. */
|
|
149
|
+
const onSubmit = async (
|
|
150
|
+
formValues: SignInFormValues,
|
|
151
|
+
{ getValues, setValues }: FormActions<SignInFormValues>,
|
|
152
|
+
): Promise<SubmitResult<SignInFormValues>> => {
|
|
153
|
+
const identifier = formValues.identifier.trim();
|
|
116
154
|
if (hidePassword) {
|
|
117
|
-
const
|
|
155
|
+
const response = await checkUsernameOrEmail({
|
|
118
156
|
variables: {
|
|
119
157
|
usernameOrEmail: identifier,
|
|
120
|
-
authCheck:
|
|
158
|
+
authCheck: !allowPublicFormEmail,
|
|
121
159
|
},
|
|
122
160
|
});
|
|
161
|
+
if (!mounted.current) {
|
|
162
|
+
return { status: 'continue' };
|
|
163
|
+
}
|
|
164
|
+
if (getValues().identifier.trim() !== identifier) {
|
|
165
|
+
resetErrors();
|
|
166
|
+
return { status: 'continue' };
|
|
167
|
+
}
|
|
168
|
+
const submission = submissionResult(response);
|
|
169
|
+
if (submission.status !== 'success') {
|
|
170
|
+
return submission;
|
|
171
|
+
}
|
|
172
|
+
const result = response?.checkUsernameOrEmail;
|
|
123
173
|
|
|
124
174
|
switch (result?.type) {
|
|
125
175
|
case 'PHONE':
|
|
126
|
-
{
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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;
|
|
176
|
+
if (!result.taken) {
|
|
177
|
+
return { status: 'error', error: { message: i18n.t('auth.no_account_with_phone') } };
|
|
178
|
+
}
|
|
179
|
+
if (result.hasPassword === false) {
|
|
180
|
+
setAuthIface('VERIFY_PHONE');
|
|
181
|
+
return { status: 'continue' };
|
|
142
182
|
}
|
|
143
183
|
break;
|
|
144
184
|
case 'EMAIL':
|
|
145
|
-
{
|
|
146
|
-
if (
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
185
|
+
if (!result.taken) {
|
|
186
|
+
if (allowPublicFormEmail) {
|
|
187
|
+
const email = identifier.toLowerCase();
|
|
188
|
+
const sent = await sendPublicFormEmailCode({ variables: { formPublicId, email } });
|
|
189
|
+
if (!mounted.current) {
|
|
190
|
+
return { status: 'continue' };
|
|
191
|
+
}
|
|
192
|
+
if (getValues().identifier.trim() !== identifier) {
|
|
193
|
+
resetErrors();
|
|
194
|
+
return { status: 'continue' };
|
|
195
|
+
}
|
|
196
|
+
const sendSubmission = submissionResult(sent);
|
|
197
|
+
if (sendSubmission.status !== 'success') {
|
|
198
|
+
return sendSubmission;
|
|
199
|
+
}
|
|
200
|
+
if (!sent?.sendPublicFormEmailCode) {
|
|
201
|
+
return { status: 'error', error: { message: i18n.t('error.30000') } };
|
|
202
|
+
}
|
|
203
|
+
setAuthIface(['VERIFY_PUBLIC_FORM_EMAIL_SENT', email]);
|
|
204
|
+
return { status: 'continue' };
|
|
156
205
|
}
|
|
206
|
+
return { status: 'error', error: { message: i18n.t('auth.no_account_with_email') } };
|
|
157
207
|
}
|
|
158
208
|
break;
|
|
159
209
|
default:
|
|
160
|
-
|
|
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;
|
|
210
|
+
return { status: 'error', error: { message: i18n.t('auth.not_valid_email_or_phone') } };
|
|
169
211
|
}
|
|
170
212
|
|
|
171
213
|
setDataForSchema({
|
|
172
214
|
...dataForSchema,
|
|
173
|
-
lastIdentifier: identifier
|
|
174
|
-
hidePassword:
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
setFormValues({
|
|
178
|
-
...formValues,
|
|
179
|
-
identifier: identifier || '',
|
|
215
|
+
lastIdentifier: identifier,
|
|
216
|
+
hidePassword: false,
|
|
180
217
|
});
|
|
218
|
+
setValues((currentValues) => ({ ...currentValues, identifier }));
|
|
181
219
|
} else if (formValues.password && identifier) {
|
|
182
220
|
setWaitingForPostRequest(true);
|
|
183
|
-
return
|
|
221
|
+
return { status: 'native' };
|
|
184
222
|
}
|
|
185
223
|
|
|
186
|
-
return
|
|
187
|
-
}
|
|
224
|
+
return { status: 'continue' };
|
|
225
|
+
};
|
|
188
226
|
|
|
189
227
|
const showSignUpLink = hidePassword && !error;
|
|
190
228
|
|
|
191
|
-
const onFinishSignIn = async (
|
|
192
|
-
token
|
|
193
|
-
sessionBootstrapToken?: string | null,
|
|
194
|
-
sessionPersisted?: boolean,
|
|
195
|
-
) => {
|
|
196
|
-
const persisted =
|
|
197
|
-
sessionPersisted ||
|
|
198
|
-
(await persistSignInSession(token, sessionBootstrapToken));
|
|
229
|
+
const onFinishSignIn = async (token: string, sessionBootstrapToken?: string | null, sessionPersisted?: boolean) => {
|
|
230
|
+
const persisted = sessionPersisted || (await persistSignInSession(token, sessionBootstrapToken));
|
|
199
231
|
if (!persisted) {
|
|
200
232
|
setError({
|
|
201
233
|
message: i18n.t('error.network_error'),
|
|
202
234
|
});
|
|
203
235
|
return false;
|
|
204
236
|
}
|
|
205
|
-
navigate(
|
|
237
|
+
navigate(getSignInSuccessRoute({ authRoutesMap, popupId, popupMode, returnTo }));
|
|
206
238
|
return true;
|
|
207
239
|
};
|
|
208
240
|
|
|
241
|
+
// Development-only password-less agent login. agentLoginAvailable is
|
|
242
|
+
// resolved server-side (true only on a local development database), so the
|
|
243
|
+
// button never shows in production.
|
|
244
|
+
const agentLoginAvailable = p.agentLoginAvailable === true;
|
|
245
|
+
const { authenticateAsAgent, saving: agentLoginSaving } = useAuthenticateAsAgent({
|
|
246
|
+
onCompleted: async (data: any) => {
|
|
247
|
+
const auth = data?.authenticateAsAgent;
|
|
248
|
+
if (!auth?.token && !auth?.sessionBootstrapToken) {
|
|
249
|
+
setError({ message: i18n.t('error.network_error') });
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
await onFinishSignIn(auth.token, auth.sessionBootstrapToken);
|
|
253
|
+
},
|
|
254
|
+
/* Forward GraphQL failures only when the callback carries an error. */
|
|
255
|
+
onError: (error) => {
|
|
256
|
+
if (error) setError(error);
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
const onClickAgentLogin = (e: { preventDefault: () => void }) => {
|
|
261
|
+
e.preventDefault();
|
|
262
|
+
const identifier = dataForSchema.lastIdentifier?.trim();
|
|
263
|
+
if (identifier) {
|
|
264
|
+
authenticateAsAgent({ variables: { identifier } });
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
// Show the agent button above the password submit button, once the account
|
|
269
|
+
// has been resolved and the password field is visible
|
|
270
|
+
const agentLoginFooter =
|
|
271
|
+
agentLoginAvailable && !hidePassword ? (
|
|
272
|
+
<FullWidthButton
|
|
273
|
+
className='mt_sm'
|
|
274
|
+
preset='bg_secondary'
|
|
275
|
+
loading={agentLoginSaving}
|
|
276
|
+
onClick={onClickAgentLogin}
|
|
277
|
+
>
|
|
278
|
+
{i18n.t('auth.agent_login')}
|
|
279
|
+
</FullWidthButton>
|
|
280
|
+
) : null;
|
|
281
|
+
|
|
209
282
|
return (
|
|
210
283
|
<>
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
284
|
+
{popupMode ? null : (
|
|
285
|
+
<>
|
|
286
|
+
<ContinueWithGoogle
|
|
287
|
+
formPublicId={formPublicId}
|
|
288
|
+
onFinishSignIn={onFinishSignIn}
|
|
289
|
+
/>
|
|
290
|
+
<ContinueWithMicrosoft
|
|
291
|
+
formPublicId={formPublicId}
|
|
292
|
+
onFinishSignIn={onFinishSignIn}
|
|
293
|
+
/>
|
|
294
|
+
<ContinueWithSso onClickButton={() => setAuthIface('SSO')} />
|
|
295
|
+
</>
|
|
296
|
+
)}
|
|
214
297
|
<ContinueWithPhone onClickButton={() => setAuthIface('VERIFY_PHONE')} />
|
|
215
298
|
|
|
216
|
-
<FormBreak
|
|
217
|
-
|
|
299
|
+
<FormBreak
|
|
300
|
+
className='mt_md'
|
|
301
|
+
colorClassName='strong_bf'
|
|
302
|
+
>
|
|
303
|
+
{i18n.t('c.or')}
|
|
218
304
|
</FormBreak>
|
|
219
305
|
|
|
220
306
|
<SchemaForm
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
dataForSchema={dataForSchema}
|
|
307
|
+
method='post'
|
|
308
|
+
actionUrl={getAuthRoute('signin', authRoutesMap, getAuthNavigationQuery(returnTo, popupMode, popupId))}
|
|
309
|
+
className='py_df'
|
|
310
|
+
initialValues={{ identifier: initialFormData?.identifier || '' }}
|
|
311
|
+
busy={saving || sendingEmailCode || waitingForPostRequest}
|
|
312
|
+
definition={signInSchema}
|
|
313
|
+
context={dataForSchema}
|
|
229
314
|
onSubmit={onSubmit}
|
|
230
|
-
|
|
315
|
+
onError={setError}
|
|
316
|
+
onValuesChange={onFormValuesChange}
|
|
317
|
+
FooterComponent={agentLoginFooter}
|
|
231
318
|
>
|
|
232
|
-
<input
|
|
319
|
+
<input
|
|
320
|
+
type='hidden'
|
|
321
|
+
name='managedSessionVersion'
|
|
322
|
+
value='1'
|
|
323
|
+
/>
|
|
233
324
|
{error && (
|
|
234
325
|
<ModalErrorMessage
|
|
235
326
|
error={error}
|
|
@@ -239,27 +330,30 @@ function SignInMain(p: AuthFormProps) {
|
|
|
239
330
|
)}
|
|
240
331
|
</SchemaForm>
|
|
241
332
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
333
|
+
{!showSignUpLink || !popupMode ? (
|
|
334
|
+
<div className='a_c'>
|
|
335
|
+
{showSignUpLink ? (
|
|
336
|
+
<Link
|
|
337
|
+
className='text ft_sm cl_md link'
|
|
338
|
+
to={getAuthRoute('signup', authRoutesMap, getAuthNavigationQuery(returnTo, popupMode, popupId))}
|
|
339
|
+
replace
|
|
340
|
+
>
|
|
341
|
+
{i18n.t('auth.signup_email')}
|
|
342
|
+
</Link>
|
|
343
|
+
) : (
|
|
344
|
+
<button
|
|
345
|
+
type='button'
|
|
346
|
+
className='text ft_sm cl_md link'
|
|
347
|
+
onClick={() => setAuthIface('REQUEST_PASSWORD_RESET')}
|
|
348
|
+
>
|
|
349
|
+
{i18n.t('auth.forgot_password_')}
|
|
350
|
+
</button>
|
|
351
|
+
)}
|
|
352
|
+
</div>
|
|
353
|
+
) : null}
|
|
260
354
|
</>
|
|
261
355
|
);
|
|
262
|
-
}
|
|
356
|
+
};
|
|
263
357
|
|
|
264
358
|
/**
|
|
265
359
|
* Forgot password form
|
|
@@ -283,19 +377,13 @@ function RequestTokenizedEmail(p: RequestTokenizedEmailProps) {
|
|
|
283
377
|
|
|
284
378
|
return {
|
|
285
379
|
...schema,
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
},
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
return obj;
|
|
298
|
-
}),
|
|
380
|
+
fields: {
|
|
381
|
+
...schema.fields,
|
|
382
|
+
email: {
|
|
383
|
+
...schema.fields.email!,
|
|
384
|
+
placeholder: initialEmailAddress,
|
|
385
|
+
},
|
|
386
|
+
},
|
|
299
387
|
};
|
|
300
388
|
}, []);
|
|
301
389
|
|
|
@@ -313,16 +401,18 @@ function RequestTokenizedEmail(p: RequestTokenizedEmailProps) {
|
|
|
313
401
|
},
|
|
314
402
|
});
|
|
315
403
|
|
|
316
|
-
|
|
317
|
-
|
|
404
|
+
/* Await the authentication request so submission state includes failures and completion. */
|
|
405
|
+
const onSubmit = async (fv: { email: string }) => {
|
|
406
|
+
const result = await requestTokenizedEmail({
|
|
318
407
|
variables: {
|
|
319
408
|
...fv,
|
|
320
409
|
requestType,
|
|
321
410
|
},
|
|
322
411
|
});
|
|
412
|
+
return submissionResult(result);
|
|
323
413
|
};
|
|
324
414
|
|
|
325
|
-
let instructionText;
|
|
415
|
+
let instructionText: string | undefined;
|
|
326
416
|
switch (requestType) {
|
|
327
417
|
case 'PASSWORD_RESET':
|
|
328
418
|
instructionText = i18n.t('auth.request_reset_password_instr');
|
|
@@ -335,18 +425,24 @@ function RequestTokenizedEmail(p: RequestTokenizedEmailProps) {
|
|
|
335
425
|
|
|
336
426
|
return (
|
|
337
427
|
<SchemaForm
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
428
|
+
busy={saving}
|
|
429
|
+
definition={tokenizedEmailSchema}
|
|
430
|
+
initialValues={{ email: initialEmailAddress || '' }}
|
|
341
431
|
onError={setError}
|
|
342
432
|
onSubmit={onSubmit}
|
|
343
433
|
buttonText={i18n.t('auth.resend_verification')}
|
|
344
434
|
>
|
|
345
435
|
{!error ? null : (
|
|
346
|
-
<ModalErrorMessage
|
|
436
|
+
<ModalErrorMessage
|
|
437
|
+
error={error}
|
|
438
|
+
resetErrors={() => setError(null)}
|
|
439
|
+
/>
|
|
347
440
|
)}
|
|
348
441
|
|
|
349
|
-
<Markdown
|
|
442
|
+
<Markdown
|
|
443
|
+
as='p'
|
|
444
|
+
className={error ? 'py_xs a_c' : '-mt_5 pb_xs a_c'}
|
|
445
|
+
>
|
|
350
446
|
{instructionText}
|
|
351
447
|
</Markdown>
|
|
352
448
|
</SchemaForm>
|
|
@@ -368,19 +464,12 @@ function ResetPasswordCompleted(p: AuthFormProps) {
|
|
|
368
464
|
return (
|
|
369
465
|
<ModalSimpleContent
|
|
370
466
|
title={i18n.t('auth.email_sent')}
|
|
371
|
-
iconName=
|
|
467
|
+
iconName='circle-check'
|
|
372
468
|
>
|
|
373
|
-
<TextWithLinks as=
|
|
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 })}
|
|
469
|
+
<TextWithLinks as='p'>
|
|
470
|
+
{i18n.t(emailAddress ? 'auth.reset_password_requested_msg' : 'auth.reset_password_requested_msg_no_email', { emailAddress })}
|
|
383
471
|
</TextWithLinks>
|
|
472
|
+
<TextWithLinks as='p'>{i18n.t('auth.if_need_more_help_email', { emailAddress: supportEmail })}</TextWithLinks>
|
|
384
473
|
</ModalSimpleContent>
|
|
385
474
|
);
|
|
386
475
|
}
|
|
@@ -391,58 +480,58 @@ function ResetPasswordCompleted(p: AuthFormProps) {
|
|
|
391
480
|
|
|
392
481
|
function SendPhoneVerification(p: AuthFormProps) {
|
|
393
482
|
const { setAuthIface } = p;
|
|
394
|
-
const sendPhoneVerificationSchema = useMemo(
|
|
395
|
-
() => makeSendPhoneVerificationSchema(),
|
|
396
|
-
[],
|
|
397
|
-
);
|
|
483
|
+
const sendPhoneVerificationSchema = useMemo(() => makeSendPhoneVerificationSchema(), []);
|
|
398
484
|
|
|
399
485
|
// Data hook
|
|
400
486
|
|
|
401
|
-
const { sendPhoneVerificationCode, saving, error, setError, resetErrors } =
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
});
|
|
487
|
+
const { sendPhoneVerificationCode, saving, error, setError, resetErrors } = useSendPhoneVerificationCode({
|
|
488
|
+
onCompleted: (data: any, _: any, variables: any) => {
|
|
489
|
+
const success = data?.sendPhoneVerificationCode;
|
|
490
|
+
if (success) {
|
|
491
|
+
setAuthIface(['VERIFY_PHONE_SENT', variables.phone]);
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
onError: (err: any) => {
|
|
495
|
+
setError(err);
|
|
496
|
+
},
|
|
497
|
+
});
|
|
413
498
|
|
|
414
|
-
|
|
415
|
-
|
|
499
|
+
/* Await the authentication request so submission state includes failures and completion. */
|
|
500
|
+
const onSubmit = async (fv: { phone: string }) => {
|
|
501
|
+
const result = await sendPhoneVerificationCode({
|
|
416
502
|
variables: {
|
|
417
503
|
phone: fv.phone,
|
|
418
504
|
},
|
|
419
505
|
});
|
|
506
|
+
return submissionResult(result);
|
|
420
507
|
};
|
|
421
508
|
|
|
422
509
|
return (
|
|
423
510
|
<>
|
|
424
511
|
<SchemaForm
|
|
425
|
-
className=
|
|
426
|
-
|
|
427
|
-
|
|
512
|
+
className='mb_df'
|
|
513
|
+
busy={saving}
|
|
514
|
+
definition={sendPhoneVerificationSchema}
|
|
428
515
|
onError={setError}
|
|
429
516
|
onSubmit={onSubmit}
|
|
430
517
|
buttonText={i18n.t('auth.send_verification_code')}
|
|
431
518
|
>
|
|
432
519
|
{!error ? null : (
|
|
433
|
-
<ModalErrorMessage
|
|
520
|
+
<ModalErrorMessage
|
|
521
|
+
error={error}
|
|
522
|
+
resetErrors={resetErrors}
|
|
523
|
+
/>
|
|
434
524
|
)}
|
|
435
525
|
|
|
436
|
-
<p className={error ? 'py_xs a_c' : '-mt_5 pb_xs a_c'}>
|
|
437
|
-
{i18n.t('auth.send_verification_code_msg')}
|
|
438
|
-
</p>
|
|
526
|
+
<p className={error ? 'py_xs a_c' : '-mt_5 pb_xs a_c'}>{i18n.t('auth.send_verification_code_msg')}</p>
|
|
439
527
|
</SchemaForm>
|
|
440
528
|
|
|
441
|
-
<div className=
|
|
529
|
+
<div className='a_c h_center'>
|
|
442
530
|
<button
|
|
531
|
+
type='button'
|
|
443
532
|
disabled={saving}
|
|
444
533
|
onClick={() => setAuthIface(null)}
|
|
445
|
-
className=
|
|
534
|
+
className='text ft_sm cl_md link'
|
|
446
535
|
>
|
|
447
536
|
{i18n.t('auth.sign_in_other_methods')}
|
|
448
537
|
</button>
|
|
@@ -460,34 +549,40 @@ interface ConfirmPhoneVerificationCodeProps extends AuthFormProps {
|
|
|
460
549
|
}
|
|
461
550
|
|
|
462
551
|
function ConfirmPhoneVerificationCode(p: ConfirmPhoneVerificationCodeProps) {
|
|
463
|
-
const { setAuthIface, phoneNumber, authRoutesMap } = p;
|
|
552
|
+
const { setAuthIface, phoneNumber, authRoutesMap, popupId, popupMode, returnTo } = p;
|
|
464
553
|
const [retryCount, setRetryCount] = useState(0);
|
|
465
554
|
const navigate = useNavigate();
|
|
466
555
|
|
|
467
556
|
// Data hook
|
|
468
557
|
|
|
469
|
-
const { confirmPhoneVerificationCode, saving, error, setError, resetErrors } =
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
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);
|
|
558
|
+
const { confirmPhoneVerificationCode, saving, error, setError, resetErrors } = useConfirmPhoneVerificationCode({
|
|
559
|
+
onCompleted: async (data: any, _: any) => {
|
|
560
|
+
const { success, token } = data?.confirmPhoneVerificationCode || {};
|
|
561
|
+
|
|
562
|
+
if (success && token) {
|
|
563
|
+
const persisted = await persistSignInSession(token);
|
|
564
|
+
if (!persisted) {
|
|
485
565
|
setError({
|
|
486
|
-
message: i18n.t('
|
|
566
|
+
message: i18n.t('error.network_error'),
|
|
487
567
|
});
|
|
568
|
+
return;
|
|
488
569
|
}
|
|
489
|
-
|
|
490
|
-
|
|
570
|
+
navigate(
|
|
571
|
+
getSignInSuccessRoute({
|
|
572
|
+
authRoutesMap,
|
|
573
|
+
popupId,
|
|
574
|
+
popupMode,
|
|
575
|
+
returnTo,
|
|
576
|
+
}),
|
|
577
|
+
);
|
|
578
|
+
} else {
|
|
579
|
+
setRetryCount(retryCount + 1);
|
|
580
|
+
setError({
|
|
581
|
+
message: i18n.t('auth.verification_code_wrong'),
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
},
|
|
585
|
+
});
|
|
491
586
|
|
|
492
587
|
const onSubmit = (code: string) => {
|
|
493
588
|
confirmPhoneVerificationCode({
|
|
@@ -501,7 +596,10 @@ function ConfirmPhoneVerificationCode(p: ConfirmPhoneVerificationCodeProps) {
|
|
|
501
596
|
return (
|
|
502
597
|
<>
|
|
503
598
|
{!error ? null : (
|
|
504
|
-
<ModalErrorMessage
|
|
599
|
+
<ModalErrorMessage
|
|
600
|
+
error={error}
|
|
601
|
+
resetErrors={resetErrors}
|
|
602
|
+
/>
|
|
505
603
|
)}
|
|
506
604
|
<SMSCodeInput
|
|
507
605
|
key={retryCount}
|
|
@@ -509,14 +607,13 @@ function ConfirmPhoneVerificationCode(p: ConfirmPhoneVerificationCodeProps) {
|
|
|
509
607
|
error={error}
|
|
510
608
|
onSubmit={onSubmit}
|
|
511
609
|
/>
|
|
512
|
-
<p className=
|
|
513
|
-
|
|
514
|
-
</p>
|
|
515
|
-
<div className="a_c h_center">
|
|
610
|
+
<p className='a_c p_n mt_md mb_df rel'>{i18n.t('auth.confirm_verification_code_instr')}</p>
|
|
611
|
+
<div className='a_c h_center'>
|
|
516
612
|
<button
|
|
613
|
+
type='button'
|
|
517
614
|
disabled={saving}
|
|
518
615
|
onClick={() => setAuthIface('VERIFY_PHONE')}
|
|
519
|
-
className=
|
|
616
|
+
className='text ft_sm cl_md link'
|
|
520
617
|
>
|
|
521
618
|
{i18n.t('auth.resend_verification_code')}
|
|
522
619
|
</button>
|
|
@@ -536,29 +633,49 @@ type SignInIface =
|
|
|
536
633
|
| 'VERIFY_EMAIL'
|
|
537
634
|
| 'EMAIL_SENT'
|
|
538
635
|
| 'VERIFY_PHONE_SENT'
|
|
636
|
+
| ['VERIFY_PUBLIC_FORM_EMAIL_SENT', string]
|
|
539
637
|
| ['VERIFY_PHONE_SENT', string];
|
|
540
638
|
|
|
541
639
|
export function SignInForm(p: Omit<AuthFormProps, 'setAuthIface'>) {
|
|
542
640
|
const { initialError } = p;
|
|
543
641
|
const errCode = initialError?.errorCode;
|
|
544
642
|
const initialIface =
|
|
545
|
-
errCode === '20053'
|
|
546
|
-
|
|
547
|
-
: errCode === '20049'
|
|
548
|
-
? 'VERIFY_EMAIL'
|
|
549
|
-
: null;
|
|
550
|
-
const [signInIface_, setAuthIface] = useState<SignInIface | null>(
|
|
551
|
-
initialIface,
|
|
552
|
-
);
|
|
643
|
+
p.initialMethod === 'PHONE' ? 'VERIFY_PHONE' : errCode === '20053' ? 'VERIFY_PHONE' : errCode === '20049' ? 'VERIFY_EMAIL' : null;
|
|
644
|
+
const [signInIface_, setAuthIface] = useState<SignInIface | null>(initialIface);
|
|
553
645
|
const ifaceIsArray = Array.isArray(signInIface_);
|
|
554
646
|
|
|
647
|
+
/* Return changed public-form emails to account discovery before choosing their authentication method. */
|
|
648
|
+
const onReturnToSignIn = () => setAuthIface(null);
|
|
649
|
+
|
|
555
650
|
switch (ifaceIsArray ? signInIface_[0] : signInIface_) {
|
|
651
|
+
case 'VERIFY_PUBLIC_FORM_EMAIL_SENT':
|
|
652
|
+
if (!p.allowPublicFormEmail || !p.formPublicId || !p.onPublicFormRespondentVerified) {
|
|
653
|
+
break;
|
|
654
|
+
}
|
|
655
|
+
return (
|
|
656
|
+
<ConfirmPublicFormEmailCode
|
|
657
|
+
formPublicId={p.formPublicId}
|
|
658
|
+
email={ifaceIsArray ? signInIface_[1] : ''}
|
|
659
|
+
onRespondentToken={p.onPublicFormRespondentVerified}
|
|
660
|
+
onChangeEmail={onReturnToSignIn}
|
|
661
|
+
/>
|
|
662
|
+
);
|
|
556
663
|
case 'SSO':
|
|
557
664
|
// Email-first SSO sign in (org home realm discovery)
|
|
558
|
-
return
|
|
665
|
+
return (
|
|
666
|
+
<SsoSignIn
|
|
667
|
+
{...p}
|
|
668
|
+
setAuthIface={setAuthIface}
|
|
669
|
+
/>
|
|
670
|
+
);
|
|
559
671
|
case 'VERIFY_PHONE':
|
|
560
672
|
// Attempted phone login but it was not verified
|
|
561
|
-
return
|
|
673
|
+
return (
|
|
674
|
+
<SendPhoneVerification
|
|
675
|
+
{...p}
|
|
676
|
+
setAuthIface={setAuthIface}
|
|
677
|
+
/>
|
|
678
|
+
);
|
|
562
679
|
case 'VERIFY_PHONE_SENT':
|
|
563
680
|
// User requested phone verification code, and it was sent
|
|
564
681
|
return (
|
|
@@ -573,7 +690,7 @@ export function SignInForm(p: Omit<AuthFormProps, 'setAuthIface'>) {
|
|
|
573
690
|
return (
|
|
574
691
|
<RequestTokenizedEmail
|
|
575
692
|
{...p}
|
|
576
|
-
requestType=
|
|
693
|
+
requestType='EMAIL_VERIFICATION'
|
|
577
694
|
setAuthIface={setAuthIface}
|
|
578
695
|
/>
|
|
579
696
|
);
|
|
@@ -581,16 +698,26 @@ export function SignInForm(p: Omit<AuthFormProps, 'setAuthIface'>) {
|
|
|
581
698
|
return (
|
|
582
699
|
<RequestTokenizedEmail
|
|
583
700
|
{...p}
|
|
584
|
-
requestType=
|
|
701
|
+
requestType='PASSWORD_RESET'
|
|
585
702
|
setAuthIface={setAuthIface}
|
|
586
703
|
/>
|
|
587
704
|
);
|
|
588
705
|
case 'EMAIL_SENT':
|
|
589
|
-
return
|
|
706
|
+
return (
|
|
707
|
+
<ResetPasswordCompleted
|
|
708
|
+
{...p}
|
|
709
|
+
setAuthIface={setAuthIface}
|
|
710
|
+
/>
|
|
711
|
+
);
|
|
590
712
|
default:
|
|
591
713
|
}
|
|
592
714
|
|
|
593
|
-
return
|
|
715
|
+
return (
|
|
716
|
+
<SignInMain
|
|
717
|
+
{...p}
|
|
718
|
+
setAuthIface={setAuthIface}
|
|
719
|
+
/>
|
|
720
|
+
);
|
|
594
721
|
}
|
|
595
722
|
|
|
596
723
|
/**
|
|
@@ -603,77 +730,80 @@ interface SignUpMainProps extends Omit<AuthFormProps, 'setAuthIface'> {
|
|
|
603
730
|
}
|
|
604
731
|
|
|
605
732
|
function SignUpMain(p: SignUpMainProps) {
|
|
606
|
-
const { authRoutesMap, initialError, setAuthIface, setSignUpToken } = p;
|
|
733
|
+
const { authRoutesMap, formPublicId, initialError, returnTo, setAuthIface, setSignUpToken } = p;
|
|
607
734
|
const navigate = useNavigate();
|
|
608
735
|
const signUpSchema = useMemo(makeSignUpSchema, []);
|
|
609
736
|
|
|
610
|
-
const { saving, signUpWithEmail, error, setError, resetErrors } =
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
const signUpToken = data?.signUpWithEmail;
|
|
737
|
+
const { saving, signUpWithEmail, error, setError, resetErrors } = useSignUpWithEmail({
|
|
738
|
+
initialError,
|
|
739
|
+
onCompleted: (data: any, _: any) => {
|
|
740
|
+
const signUpToken = data?.signUpWithEmail;
|
|
615
741
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
742
|
+
if (signUpToken) {
|
|
743
|
+
setSignUpToken(signUpToken);
|
|
744
|
+
}
|
|
745
|
+
},
|
|
746
|
+
onError: (err: any) => {
|
|
747
|
+
if (err?.errorCode === '20054') {
|
|
748
|
+
setAuthIface('INVITATION_REQUIRED');
|
|
749
|
+
}
|
|
750
|
+
},
|
|
751
|
+
});
|
|
626
752
|
|
|
627
|
-
|
|
628
|
-
|
|
753
|
+
/* Await the authentication request so submission state includes failures and completion. */
|
|
754
|
+
const onSubmit = async (formValues: { email: string; password: string; passwordRepeat: string }) => {
|
|
755
|
+
const result = await signUpWithEmail({
|
|
629
756
|
variables: {
|
|
630
757
|
emailAddress: formValues.email,
|
|
631
758
|
password: formValues.password,
|
|
632
759
|
},
|
|
633
760
|
});
|
|
761
|
+
return submissionResult(result);
|
|
634
762
|
};
|
|
635
763
|
|
|
636
764
|
// SSO providers auto-create accounts, so they work as sign up too
|
|
637
|
-
const onFinishSignIn = async (
|
|
638
|
-
token
|
|
639
|
-
sessionBootstrapToken?: string | null,
|
|
640
|
-
sessionPersisted?: boolean,
|
|
641
|
-
) => {
|
|
642
|
-
const persisted =
|
|
643
|
-
sessionPersisted ||
|
|
644
|
-
(await persistSignInSession(token, sessionBootstrapToken));
|
|
765
|
+
const onFinishSignIn = async (token: string, sessionBootstrapToken?: string | null, sessionPersisted?: boolean) => {
|
|
766
|
+
const persisted = sessionPersisted || (await persistSignInSession(token, sessionBootstrapToken));
|
|
645
767
|
if (!persisted) {
|
|
646
768
|
setError({
|
|
647
769
|
message: i18n.t('error.network_error'),
|
|
648
770
|
});
|
|
649
771
|
return false;
|
|
650
772
|
}
|
|
651
|
-
navigate(getAuthRoute('signin_success', authRoutesMap));
|
|
773
|
+
navigate(getAuthRoute('signin_success', authRoutesMap, getAuthReturnQuery(returnTo)));
|
|
652
774
|
return true;
|
|
653
775
|
};
|
|
654
776
|
|
|
655
777
|
return (
|
|
656
778
|
<>
|
|
657
|
-
<ContinueWithGoogle
|
|
658
|
-
|
|
779
|
+
<ContinueWithGoogle
|
|
780
|
+
formPublicId={formPublicId}
|
|
781
|
+
onFinishSignIn={onFinishSignIn}
|
|
782
|
+
/>
|
|
783
|
+
<ContinueWithMicrosoft
|
|
784
|
+
formPublicId={formPublicId}
|
|
785
|
+
onFinishSignIn={onFinishSignIn}
|
|
786
|
+
/>
|
|
659
787
|
|
|
660
|
-
<FormBreak
|
|
661
|
-
|
|
788
|
+
<FormBreak
|
|
789
|
+
className='mt_md'
|
|
790
|
+
colorClassName='strong_bf'
|
|
791
|
+
>
|
|
792
|
+
{i18n.t('c.or')}
|
|
662
793
|
</FormBreak>
|
|
663
794
|
|
|
664
795
|
<SchemaForm
|
|
665
|
-
className=
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
// currentData={{}}
|
|
796
|
+
className='py_df'
|
|
797
|
+
busy={saving}
|
|
798
|
+
definition={signUpSchema}
|
|
669
799
|
onError={setError}
|
|
670
800
|
onSubmit={onSubmit}
|
|
671
801
|
buttonText={i18n.t('auth.agree_and_continue')}
|
|
672
802
|
FooterComponent={
|
|
673
803
|
<TextWithLinks
|
|
674
|
-
as=
|
|
675
|
-
className=
|
|
676
|
-
linkClassName=
|
|
804
|
+
as='div'
|
|
805
|
+
className='ft_xs mt_sm cl_md'
|
|
806
|
+
linkClassName='u link cl_md'
|
|
677
807
|
>
|
|
678
808
|
{i18n.t('auth.sign_up_notice_msg')}
|
|
679
809
|
</TextWithLinks>
|
|
@@ -688,11 +818,11 @@ function SignUpMain(p: SignUpMainProps) {
|
|
|
688
818
|
)}
|
|
689
819
|
</SchemaForm>
|
|
690
820
|
|
|
691
|
-
<div className=
|
|
821
|
+
<div className='a_c h_center'>
|
|
692
822
|
<Link
|
|
693
|
-
to={getAuthRoute('signin', authRoutesMap)}
|
|
823
|
+
to={getAuthRoute('signin', authRoutesMap, getAuthReturnQuery(returnTo))}
|
|
694
824
|
replace
|
|
695
|
-
className=
|
|
825
|
+
className='text ft_sm cl_md link'
|
|
696
826
|
>
|
|
697
827
|
{i18n.t('auth.sign_in_w_existing')}
|
|
698
828
|
</Link>
|
|
@@ -705,17 +835,15 @@ function SignUpMain(p: SignUpMainProps) {
|
|
|
705
835
|
* Sign up; invitation required
|
|
706
836
|
*/
|
|
707
837
|
|
|
708
|
-
function SignUpInviteRequired(
|
|
838
|
+
function SignUpInviteRequired(_p: Omit<AuthFormProps, 'setAuthIface'>) {
|
|
709
839
|
const supportEmail = APP_EMAILS.support;
|
|
710
840
|
|
|
711
841
|
return (
|
|
712
842
|
<ModalSimpleContent
|
|
713
843
|
title={i18n.t('auth.invite_required')}
|
|
714
|
-
iconName=
|
|
844
|
+
iconName='mailbox-filled'
|
|
715
845
|
>
|
|
716
|
-
<TextWithLinks as=
|
|
717
|
-
{i18n.t('auth.invite_required_msg', { emailAddress: supportEmail })}
|
|
718
|
-
</TextWithLinks>
|
|
846
|
+
<TextWithLinks as='p'>{i18n.t('auth.invite_required_msg', { emailAddress: supportEmail })}</TextWithLinks>
|
|
719
847
|
</ModalSimpleContent>
|
|
720
848
|
);
|
|
721
849
|
}
|
|
@@ -729,20 +857,20 @@ interface SignUpSuccessProps extends Omit<AuthFormProps, 'setAuthIface'> {
|
|
|
729
857
|
}
|
|
730
858
|
|
|
731
859
|
function SignUpSuccess(p: SignUpSuccessProps) {
|
|
732
|
-
const { authRoutesMap } = p;
|
|
860
|
+
const { authRoutesMap, returnTo } = p;
|
|
733
861
|
|
|
734
862
|
return (
|
|
735
863
|
<ModalSimpleContent
|
|
736
864
|
title={i18n.t('auth.account_created')}
|
|
737
|
-
iconName=
|
|
738
|
-
className=
|
|
865
|
+
iconName='circle-check'
|
|
866
|
+
className='px_df pt_md'
|
|
739
867
|
>
|
|
740
|
-
<TextWithLinks as=
|
|
868
|
+
<TextWithLinks as='p'>{i18n.t('auth.account_created_msg')}</TextWithLinks>
|
|
741
869
|
|
|
742
870
|
<FullWidthButton
|
|
743
|
-
to={getAuthRoute('signin', authRoutesMap)}
|
|
744
|
-
preset=
|
|
745
|
-
className=
|
|
871
|
+
to={getAuthRoute('signin', authRoutesMap, getAuthReturnQuery(returnTo))}
|
|
872
|
+
preset='bg_primary'
|
|
873
|
+
className='mt_lg shadow'
|
|
746
874
|
replace
|
|
747
875
|
>
|
|
748
876
|
{i18n.t('auth.continue_to_login')}
|
|
@@ -762,7 +890,12 @@ export function SignUpForm(p: Omit<AuthFormProps, 'setAuthIface'>) {
|
|
|
762
890
|
const [signUpIface, setAuthIface] = useState<SignUpIface>(null);
|
|
763
891
|
|
|
764
892
|
if (signUpToken) {
|
|
765
|
-
return
|
|
893
|
+
return (
|
|
894
|
+
<SignUpSuccess
|
|
895
|
+
{...p}
|
|
896
|
+
signUpToken={signUpToken}
|
|
897
|
+
/>
|
|
898
|
+
);
|
|
766
899
|
}
|
|
767
900
|
|
|
768
901
|
switch (signUpIface) {
|