@micha.bigler/ui-core-micha 4.37.1 → 4.38.0
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/README.md +5 -1
- package/dist/auth/authApi.js +26 -1
- package/dist/components/SignUpContent.js +11 -8
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -137,7 +137,11 @@ project, import or payment work. Existing pages and the dialog `OnboardingProvid
|
|
|
137
137
|
email. `showProviders` adds Google/Microsoft above the form. `preferredSignupMode` (also on `SignUpPage`, e.g.
|
|
138
138
|
`'self_signup_open'`) shows that mode first and selected when the server offers it; otherwise it is ignored and the
|
|
139
139
|
server order applies. Open self-signup submits with "Konto anlegen" (`Auth.SIGNUP_SUBMIT_OPEN`); the other modes
|
|
140
|
-
keep "Einladung anfordern".
|
|
140
|
+
keep "Einladung anfordern". An embedding app may pass `renderAdditionalField({ disabled })` to render its own optional
|
|
141
|
+
field inside the shared form and `additionalRegistrationData` as a flat object of its request keys and values. The
|
|
142
|
+
app owns field labels, translations, validation and error text. Empty values are omitted, and keys that could replace
|
|
143
|
+
the email, mode, access code, QR token or Turnstile token are ignored. The component does not persist this data or
|
|
144
|
+
place it in a URL or logs; the host should keep it transient as well.
|
|
141
145
|
- `SignupConfirmContent` — the password form of `SignupConfirmPage`. Pass `token` (from the emailed
|
|
142
146
|
`/signup/confirm/?token=…` link, which your app routes) and `onSuccess()`; there is no automatic sign-in, show
|
|
143
147
|
`LoginContent` next.
|
package/dist/auth/authApi.js
CHANGED
|
@@ -350,7 +350,7 @@ export async function sendAdminInvite(email) {
|
|
|
350
350
|
throw normaliseApiError(error, 'Auth.INVITE_FAILED');
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
|
-
export async function submitRegistrationRequest({ email, mode, accessCode, registrationContextToken, registrationContext, turnstileToken, }) {
|
|
353
|
+
export async function submitRegistrationRequest({ email, mode, accessCode, registrationContextToken, registrationContext, turnstileToken, additionalRegistrationData, }) {
|
|
354
354
|
const payload = { email, mode };
|
|
355
355
|
if (accessCode)
|
|
356
356
|
payload.access_code = accessCode;
|
|
@@ -362,6 +362,31 @@ export async function submitRegistrationRequest({ email, mode, accessCode, regis
|
|
|
362
362
|
}
|
|
363
363
|
if (turnstileToken)
|
|
364
364
|
payload.turnstile_token = turnstileToken;
|
|
365
|
+
const protectedRegistrationFields = new Set([
|
|
366
|
+
'email',
|
|
367
|
+
'mode',
|
|
368
|
+
'accessCode',
|
|
369
|
+
'access_code',
|
|
370
|
+
'registrationContextToken',
|
|
371
|
+
'registration_context_token',
|
|
372
|
+
'registrationContext',
|
|
373
|
+
'registration_context',
|
|
374
|
+
'turnstileToken',
|
|
375
|
+
'turnstile_token',
|
|
376
|
+
'__proto__',
|
|
377
|
+
'prototype',
|
|
378
|
+
'constructor',
|
|
379
|
+
]);
|
|
380
|
+
if (additionalRegistrationData && typeof additionalRegistrationData === 'object') {
|
|
381
|
+
for (const [key, value] of Object.entries(additionalRegistrationData)) {
|
|
382
|
+
if (!protectedRegistrationFields.has(key)
|
|
383
|
+
&& value !== undefined
|
|
384
|
+
&& value !== null
|
|
385
|
+
&& value !== '') {
|
|
386
|
+
payload[key] = value;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
365
390
|
try {
|
|
366
391
|
const res = await apiClient.post(`${USERS_BASE}/register-request/`, payload);
|
|
367
392
|
return res.data;
|
|
@@ -54,9 +54,16 @@ export function orderSignupModes(modes, preferredMode) {
|
|
|
54
54
|
* - `showProviders` (default false) and `continuation`: Google/Microsoft entry
|
|
55
55
|
* above the email form when the app enables it; the validated continuation is
|
|
56
56
|
* the provider callback URL.
|
|
57
|
+
* - `renderAdditionalField({ disabled })`: optional host-rendered field placed
|
|
58
|
+
* in the form. The host owns its label, translations, validation and error
|
|
59
|
+
* text; `disabled` follows the shared form's submitting state.
|
|
60
|
+
* - `additionalRegistrationData`: optional flat object of app-owned request
|
|
61
|
+
* fields. Empty values are omitted and protected registration fields are
|
|
62
|
+
* ignored by the request helper. Keep this value in transient component state;
|
|
63
|
+
* the shared form does not persist it or add it to a URL or logs.
|
|
57
64
|
* The access code, QR token and Turnstile token never leave this component.
|
|
58
65
|
*/
|
|
59
|
-
export function SignUpContent({ registrationContextToken = '', preferredSignupMode, onModeChange, onSubmitted, showProviders = false, continuation, }) {
|
|
66
|
+
export function SignUpContent({ registrationContextToken = '', preferredSignupMode, onModeChange, onSubmitted, showProviders = false, continuation, renderAdditionalField, additionalRegistrationData, }) {
|
|
60
67
|
const { t, i18n } = useTranslation();
|
|
61
68
|
const { authMethods } = useContext(AuthContext) || {};
|
|
62
69
|
const serverSignupModes = useMemo(() => resolveSignupModes(authMethods), [authMethods]);
|
|
@@ -126,13 +133,9 @@ export function SignUpContent({ registrationContextToken = '', preferredSignupMo
|
|
|
126
133
|
return;
|
|
127
134
|
setSubmitting(true);
|
|
128
135
|
try {
|
|
129
|
-
const res = await submitRegistrationRequest({
|
|
130
|
-
email,
|
|
136
|
+
const res = await submitRegistrationRequest(Object.assign({ email,
|
|
131
137
|
mode,
|
|
132
|
-
accessCode,
|
|
133
|
-
registrationContextToken: mode === 'self_signup_qr' ? registrationContextToken : null,
|
|
134
|
-
turnstileToken: turnstileRequired ? turnstileToken : undefined,
|
|
135
|
-
});
|
|
138
|
+
accessCode, registrationContextToken: mode === 'self_signup_qr' ? registrationContextToken : null, turnstileToken: turnstileRequired ? turnstileToken : undefined }, (additionalRegistrationData ? { additionalRegistrationData } : {})));
|
|
136
139
|
// The backend's own response code is already mode-agnostic and accurate
|
|
137
140
|
// (Auth.INVITE_SENT). Falling back to the access-code-specific "if valid,
|
|
138
141
|
// an invite was sent" wording here was wrong for open/email-domain/QR
|
|
@@ -157,7 +160,7 @@ export function SignUpContent({ registrationContextToken = '', preferredSignupMo
|
|
|
157
160
|
if (onSubmitted && successKey) {
|
|
158
161
|
return (_jsxs(Stack, { spacing: 2, children: [_jsx(Alert, { severity: "success", children: t(successKey, { email }) }), _jsx(Alert, { severity: "info", children: t('Auth.CONFIRMATION_EMAIL_INSTRUCTION') })] }));
|
|
159
162
|
}
|
|
160
|
-
return (_jsxs(_Fragment, { children: [successKey && (_jsx(Alert, { severity: "success", sx: SIGN_UP_PAGE_ALERT_SX, children: t(successKey, { email }) })), errorKey && (_jsx(Alert, { severity: "error", sx: SIGN_UP_PAGE_ALERT_SX, children: errorKey })), providersVisible && (_jsxs(Box, { sx: { mb: 2 }, children: [_jsx(SocialLoginButtons, { onProviderClick: handleProviderLogin, providers: socialProviders }), providerTransition && (_jsx(Alert, { severity: "info", sx: SIGN_UP_PROVIDER_ALERT_SX, children: t('Auth.PROVIDER_TRANSITION', { provider: PROVIDER_NAMES[providerTransition] || providerTransition }) })), _jsx(Divider, { sx: SIGN_UP_PROVIDER_DIVIDER_SX, children: t('Auth.LOGIN_OR') })] })), signupModes.length > 1 && (_jsx(Stack, { spacing: 1, sx: { mb: 2 }, children: signupModes.map((entry) => (_jsx(Button, { variant: mode === entry ? 'contained' : 'outlined', onClick: () => setMode(entry), disabled: submitting, fullWidth: true, children: t(MODE_LABELS[entry] || entry, entry) }, entry))) })), _jsxs(Box, { component: "form", onSubmit: handleSubmit, sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [_jsx(TextField, { label: t('Auth.EMAIL_LABEL'), type: "email", required: true, fullWidth: true, value: email, onChange: (e) => setEmail(e.target.value), disabled: submitting }), mode === 'self_signup_access_code' && (_jsx(TextField, { label: t('Auth.ACCESS_CODE_LABEL'), type: "text", required: true, fullWidth: true, value: accessCode, onChange: (e) => setAccessCode(e.target.value), disabled: submitting })), turnstileRequired && (_jsx(TurnstileWidget, { ref: turnstileWidgetRef, siteKey: authMethods.turnstile_site_key, onToken: setTurnstileToken })), _jsx(Button, { type: "submit", variant: "contained", disabled: submitting || Boolean(providerTransition) || (turnstileRequired && !turnstileToken), children: submitting
|
|
163
|
+
return (_jsxs(_Fragment, { children: [successKey && (_jsx(Alert, { severity: "success", sx: SIGN_UP_PAGE_ALERT_SX, children: t(successKey, { email }) })), errorKey && (_jsx(Alert, { severity: "error", sx: SIGN_UP_PAGE_ALERT_SX, children: errorKey })), providersVisible && (_jsxs(Box, { sx: { mb: 2 }, children: [_jsx(SocialLoginButtons, { onProviderClick: handleProviderLogin, providers: socialProviders }), providerTransition && (_jsx(Alert, { severity: "info", sx: SIGN_UP_PROVIDER_ALERT_SX, children: t('Auth.PROVIDER_TRANSITION', { provider: PROVIDER_NAMES[providerTransition] || providerTransition }) })), _jsx(Divider, { sx: SIGN_UP_PROVIDER_DIVIDER_SX, children: t('Auth.LOGIN_OR') })] })), signupModes.length > 1 && (_jsx(Stack, { spacing: 1, sx: { mb: 2 }, children: signupModes.map((entry) => (_jsx(Button, { variant: mode === entry ? 'contained' : 'outlined', onClick: () => setMode(entry), disabled: submitting, fullWidth: true, children: t(MODE_LABELS[entry] || entry, entry) }, entry))) })), _jsxs(Box, { component: "form", onSubmit: handleSubmit, sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [_jsx(TextField, { label: t('Auth.EMAIL_LABEL'), type: "email", required: true, fullWidth: true, value: email, onChange: (e) => setEmail(e.target.value), disabled: submitting }), mode === 'self_signup_access_code' && (_jsx(TextField, { label: t('Auth.ACCESS_CODE_LABEL'), type: "text", required: true, fullWidth: true, value: accessCode, onChange: (e) => setAccessCode(e.target.value), disabled: submitting })), renderAdditionalField === null || renderAdditionalField === void 0 ? void 0 : renderAdditionalField({ disabled: submitting }), turnstileRequired && (_jsx(TurnstileWidget, { ref: turnstileWidgetRef, siteKey: authMethods.turnstile_site_key, onToken: setTurnstileToken })), _jsx(Button, { type: "submit", variant: "contained", disabled: submitting || Boolean(providerTransition) || (turnstileRequired && !turnstileToken), children: submitting
|
|
161
164
|
? t('Auth.SIGNUP_SUBMITTING')
|
|
162
165
|
: t(mode === 'self_signup_open' ? 'Auth.SIGNUP_SUBMIT_OPEN' : 'Auth.SIGNUP_SUBMIT') })] })] }));
|
|
163
166
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micha.bigler/ui-core-micha",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.38.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"@mui/icons-material": "^7.3.11",
|
|
71
71
|
"@mui/x-charts": "^8.29.3",
|
|
72
72
|
"@testing-library/react": "^16.3.3",
|
|
73
|
+
"@testing-library/user-event": "14.6.1",
|
|
73
74
|
"@vitejs/plugin-react": "^6.2.1",
|
|
74
75
|
"i18next": "^26.7.1",
|
|
75
76
|
"jsdom": "^30.1.3",
|