hazo_auth 10.24.0 → 10.26.1
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/cli-src/lib/already_logged_in_config.server.ts +13 -0
- package/cli-src/lib/auth/auth_types.ts +6 -0
- package/cli-src/lib/auth/hazo_get_auth.server.ts +3 -0
- package/cli-src/lib/location_fields_config.server.ts +42 -0
- package/cli-src/lib/login_config.server.ts +3 -0
- package/cli-src/lib/my_settings_config.server.ts +6 -0
- package/cli-src/lib/register_config.server.ts +16 -0
- package/cli-src/lib/services/location_fields_helper.ts +30 -0
- package/cli-src/lib/services/registration_service.ts +21 -0
- package/cli-src/lib/services/user_update_service.ts +7 -0
- package/dist/components/layouts/legal/legal_acceptance_gate.d.ts +1 -1
- package/dist/components/layouts/legal/legal_acceptance_gate.d.ts.map +1 -1
- package/dist/components/layouts/legal/legal_acceptance_gate.js +5 -3
- package/dist/components/layouts/login/index.d.ts +8 -1
- package/dist/components/layouts/login/index.d.ts.map +1 -1
- package/dist/components/layouts/login/index.js +2 -2
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts +8 -0
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/hooks/use_my_settings.js +37 -0
- package/dist/components/layouts/my_settings/index.d.ts +6 -1
- package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/index.js +3 -3
- package/dist/components/layouts/register/hooks/use_register_form.d.ts +15 -1
- package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -1
- package/dist/components/layouts/register/hooks/use_register_form.js +69 -4
- package/dist/components/layouts/register/index.d.ts +7 -1
- package/dist/components/layouts/register/index.d.ts.map +1 -1
- package/dist/components/layouts/register/index.js +30 -4
- package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts +8 -1
- package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/already_logged_in_guard.js +15 -1
- package/dist/components/layouts/shared/hooks/use_auth_status.d.ts +3 -0
- package/dist/components/layouts/shared/hooks/use_auth_status.d.ts.map +1 -1
- package/dist/components/layouts/shared/hooks/use_auth_status.js +5 -2
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/lib/already_logged_in_config.server.d.ts +8 -0
- package/dist/lib/already_logged_in_config.server.d.ts.map +1 -1
- package/dist/lib/already_logged_in_config.server.js +4 -0
- package/dist/lib/auth/auth_types.d.ts +3 -0
- package/dist/lib/auth/auth_types.d.ts.map +1 -1
- package/dist/lib/auth/hazo_get_auth.server.d.ts.map +1 -1
- package/dist/lib/auth/hazo_get_auth.server.js +3 -0
- package/dist/lib/location_fields_config.server.d.ts +22 -0
- package/dist/lib/location_fields_config.server.d.ts.map +1 -0
- package/dist/lib/location_fields_config.server.js +31 -0
- package/dist/lib/login_config.server.d.ts +2 -0
- package/dist/lib/login_config.server.d.ts.map +1 -1
- package/dist/lib/login_config.server.js +1 -0
- package/dist/lib/my_settings_config.server.d.ts +4 -0
- package/dist/lib/my_settings_config.server.d.ts.map +1 -1
- package/dist/lib/my_settings_config.server.js +3 -0
- package/dist/lib/register_config.server.d.ts +10 -0
- package/dist/lib/register_config.server.d.ts.map +1 -1
- package/dist/lib/register_config.server.js +7 -0
- package/dist/lib/services/location_fields_helper.d.ts +13 -0
- package/dist/lib/services/location_fields_helper.d.ts.map +1 -0
- package/dist/lib/services/location_fields_helper.js +24 -0
- package/dist/lib/services/registration_service.d.ts +9 -0
- package/dist/lib/services/registration_service.d.ts.map +1 -1
- package/dist/lib/services/registration_service.js +11 -0
- package/dist/lib/services/user_update_service.d.ts +5 -0
- package/dist/lib/services/user_update_service.d.ts.map +1 -1
- package/dist/lib/services/user_update_service.js +2 -0
- package/dist/locales/en.json +9 -0
- package/dist/page_components/my_settings.d.ts +9 -1
- package/dist/page_components/my_settings.d.ts.map +1 -1
- package/dist/page_components/my_settings.js +8 -2
- package/dist/server/routes/me.d.ts.map +1 -1
- package/dist/server/routes/me.js +5 -1
- package/dist/server/routes/register.d.ts.map +1 -1
- package/dist/server/routes/register.js +46 -0
- package/dist/server/routes/update_user.d.ts.map +1 -1
- package/dist/server/routes/update_user.js +24 -1
- package/dist/server_pages/login.d.ts.map +1 -1
- package/dist/server_pages/login.js +1 -1
- package/dist/server_pages/login_client_wrapper.d.ts +1 -1
- package/dist/server_pages/login_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/login_client_wrapper.js +2 -2
- package/dist/server_pages/my_settings.d.ts.map +1 -1
- package/dist/server_pages/my_settings.js +1 -1
- package/dist/server_pages/register.d.ts.map +1 -1
- package/dist/server_pages/register.js +1 -1
- package/dist/server_pages/register_client_wrapper.d.ts +4 -2
- package/dist/server_pages/register_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/register_client_wrapper.js +2 -2
- package/package.json +11 -11
|
@@ -2,6 +2,8 @@ import type { LayoutDataClient } from "../../shared/data/layout_data_client";
|
|
|
2
2
|
import type { PasswordRequirementOptions, PasswordRequirementOverrides } from "../../shared/config/layout_customization";
|
|
3
3
|
import { type RegisterFieldId } from "../config/register_field_config.js";
|
|
4
4
|
import type { LegalDoc } from "../../../../lib/legal/legal_docs_types";
|
|
5
|
+
import type { LocationFieldsConfig } from "../../../../lib/location_fields_config.server";
|
|
6
|
+
import type { AppUserDataSchema } from "../../../../lib/app_user_data_config.server";
|
|
5
7
|
export type RegisterFormValues = Record<RegisterFieldId, string>;
|
|
6
8
|
export type RegisterFormErrors = Partial<Record<RegisterFieldId, string | string[]>> & {
|
|
7
9
|
submit?: string;
|
|
@@ -14,7 +16,15 @@ export type UseRegisterFormParams<TClient = unknown> = {
|
|
|
14
16
|
dataClient: LayoutDataClient<TClient>;
|
|
15
17
|
urlOnLogon?: string;
|
|
16
18
|
legalDocs?: LegalDoc[];
|
|
19
|
+
/** Which indexed location fields to collect — see [hazo_auth__custom_fields]. */
|
|
20
|
+
locationFields?: LocationFieldsConfig;
|
|
21
|
+
/** Arbitrary custom fields, reusing the existing app_user_data JSON Schema config.
|
|
22
|
+
* Only flat `string` | `number` | `boolean` top-level properties are rendered at
|
|
23
|
+
* registration time — nested `object` properties are edited later via User
|
|
24
|
+
* Management's schema editor, not at signup. */
|
|
25
|
+
customFieldsSchema?: AppUserDataSchema | null;
|
|
17
26
|
};
|
|
27
|
+
export type LocationFieldKey = "country" | "state_province" | "suburb";
|
|
18
28
|
export type UseRegisterFormResult = {
|
|
19
29
|
values: RegisterFormValues;
|
|
20
30
|
errors: RegisterFormErrors;
|
|
@@ -29,6 +39,10 @@ export type UseRegisterFormResult = {
|
|
|
29
39
|
handleCancel: () => void;
|
|
30
40
|
legal_accepted: Record<string, boolean>;
|
|
31
41
|
handleLegalAcceptedChange: (key: string, value: boolean) => void;
|
|
42
|
+
locationValues: Record<LocationFieldKey, string>;
|
|
43
|
+
handleLocationFieldChange: (field: LocationFieldKey, value: string) => void;
|
|
44
|
+
customFieldValues: Record<string, string>;
|
|
45
|
+
handleCustomFieldChange: (key: string, value: string) => void;
|
|
32
46
|
};
|
|
33
|
-
export declare const use_register_form: <TClient>({ showNameField, passwordRequirements, dataClient, urlOnLogon, legalDocs, }: UseRegisterFormParams<TClient>) => UseRegisterFormResult;
|
|
47
|
+
export declare const use_register_form: <TClient>({ showNameField, passwordRequirements, dataClient, urlOnLogon, legalDocs, locationFields, customFieldsSchema, }: UseRegisterFormParams<TClient>) => UseRegisterFormResult;
|
|
34
48
|
//# sourceMappingURL=use_register_form.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_register_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/register/hooks/use_register_form.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACzH,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAG3F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"use_register_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/register/hooks/use_register_form.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACzH,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAG3F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAGvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAC1F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AASrF,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AACjE,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,GAAG;IACrF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C,OAAO,CAAC,eAAe,EAAE,UAAU,GAAG,kBAAkB,CAAC,EACzD,OAAO,CACR,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,OAAO,GAAG,OAAO,IAAI;IACrD,aAAa,EAAE,OAAO,CAAC;IACvB,oBAAoB,EAAE,0BAA0B,CAAC;IACjD,4BAA4B,CAAC,EAAE,4BAA4B,CAAC;IAC5D,UAAU,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,iFAAiF;IACjF,cAAc,CAAC,EAAE,oBA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,iHAQzC,qBAAqB,CAAC,OAAO,CAAC,KAAG,qBAmVnC,CAAC"}
|
|
@@ -18,7 +18,7 @@ const buildInitialValues = () => ({
|
|
|
18
18
|
[REGISTER_FIELD_IDS.CONFIRM_PASSWORD]: "",
|
|
19
19
|
});
|
|
20
20
|
// section: hook
|
|
21
|
-
export const use_register_form = ({ showNameField, passwordRequirements, dataClient, urlOnLogon, legalDocs, }) => {
|
|
21
|
+
export const use_register_form = ({ showNameField, passwordRequirements, dataClient, urlOnLogon, legalDocs, locationFields, customFieldsSchema, }) => {
|
|
22
22
|
const { apiBasePath } = useHazoAuthConfig();
|
|
23
23
|
const t = useAuthT();
|
|
24
24
|
const initialValues = useMemo(() => buildInitialValues(), []);
|
|
@@ -31,6 +31,18 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
31
31
|
const [emailTouched, setEmailTouched] = useState(false);
|
|
32
32
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
33
33
|
const [legal_accepted, set_legal_accepted] = useState({});
|
|
34
|
+
const [locationValues, setLocationValues] = useState({
|
|
35
|
+
country: "",
|
|
36
|
+
state_province: "",
|
|
37
|
+
suburb: "",
|
|
38
|
+
});
|
|
39
|
+
const [customFieldValues, setCustomFieldValues] = useState({});
|
|
40
|
+
const handleLocationFieldChange = useCallback((field, value) => {
|
|
41
|
+
setLocationValues((prev) => (Object.assign(Object.assign({}, prev), { [field]: value })));
|
|
42
|
+
}, []);
|
|
43
|
+
const handleCustomFieldChange = useCallback((key, value) => {
|
|
44
|
+
setCustomFieldValues((prev) => (Object.assign(Object.assign({}, prev), { [key]: value })));
|
|
45
|
+
}, []);
|
|
34
46
|
// Check if form has been edited (changed from initial state)
|
|
35
47
|
const isFormEdited = useMemo(() => {
|
|
36
48
|
return Object.entries(values).some(([fieldId, fieldValue]) => {
|
|
@@ -158,14 +170,48 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
158
170
|
.filter(doc => legal_accepted[doc.key])
|
|
159
171
|
.map(doc => [doc.key, { hash: doc.hash }]))
|
|
160
172
|
: undefined;
|
|
173
|
+
// Only send fields the app actually enabled, and only non-blank ones —
|
|
174
|
+
// mirrors the server-side re-validation in register.ts (never trust the
|
|
175
|
+
// client alone, but no point sending what the server would strip anyway).
|
|
176
|
+
const location_payload = {};
|
|
177
|
+
if ((locationFields === null || locationFields === void 0 ? void 0 : locationFields.country) && locationValues.country.trim()) {
|
|
178
|
+
location_payload.country = locationValues.country.trim();
|
|
179
|
+
}
|
|
180
|
+
if ((locationFields === null || locationFields === void 0 ? void 0 : locationFields.state_province) && locationValues.state_province.trim()) {
|
|
181
|
+
location_payload.state_province = locationValues.state_province.trim();
|
|
182
|
+
}
|
|
183
|
+
if ((locationFields === null || locationFields === void 0 ? void 0 : locationFields.suburb) && locationValues.suburb.trim()) {
|
|
184
|
+
location_payload.suburb = locationValues.suburb.trim();
|
|
185
|
+
}
|
|
186
|
+
const custom_fields_payload = {};
|
|
187
|
+
if (customFieldsSchema) {
|
|
188
|
+
for (const [key, propertySchema] of Object.entries(customFieldsSchema.properties)) {
|
|
189
|
+
const raw = customFieldValues[key];
|
|
190
|
+
if (raw === undefined || raw === "")
|
|
191
|
+
continue;
|
|
192
|
+
if (propertySchema.type === "number") {
|
|
193
|
+
const parsed = Number(raw);
|
|
194
|
+
if (!Number.isNaN(parsed))
|
|
195
|
+
custom_fields_payload[key] = parsed;
|
|
196
|
+
}
|
|
197
|
+
else if (propertySchema.type === "boolean") {
|
|
198
|
+
custom_fields_payload[key] = raw === "true";
|
|
199
|
+
}
|
|
200
|
+
else if (propertySchema.type === "string") {
|
|
201
|
+
custom_fields_payload[key] = raw;
|
|
202
|
+
}
|
|
203
|
+
// "object"-typed top-level properties aren't rendered at registration
|
|
204
|
+
// time (see UseRegisterFormParams.customFieldsSchema doc) — skipped.
|
|
205
|
+
}
|
|
206
|
+
}
|
|
161
207
|
const response = await fetch(`${apiBasePath}/register`, {
|
|
162
208
|
method: "POST",
|
|
163
209
|
headers: {
|
|
164
210
|
"Content-Type": "application/json",
|
|
165
211
|
},
|
|
166
|
-
body: JSON.stringify(Object.assign({ name: values[REGISTER_FIELD_IDS.NAME] || undefined, email: values[REGISTER_FIELD_IDS.EMAIL], password: values[REGISTER_FIELD_IDS.PASSWORD], url_on_logon: urlOnLogon }, (legal_accepted_payload && Object.keys(legal_accepted_payload).length > 0
|
|
212
|
+
body: JSON.stringify(Object.assign(Object.assign(Object.assign({ name: values[REGISTER_FIELD_IDS.NAME] || undefined, email: values[REGISTER_FIELD_IDS.EMAIL], password: values[REGISTER_FIELD_IDS.PASSWORD], url_on_logon: urlOnLogon }, (legal_accepted_payload && Object.keys(legal_accepted_payload).length > 0
|
|
167
213
|
? { legal_accepted: legal_accepted_payload }
|
|
168
|
-
: {}))),
|
|
214
|
+
: {})), (Object.keys(location_payload).length > 0 ? { location: location_payload } : {})), (Object.keys(custom_fields_payload).length > 0 ? { custom_fields: custom_fields_payload } : {}))),
|
|
169
215
|
});
|
|
170
216
|
const data = await response.json();
|
|
171
217
|
if (!response.ok) {
|
|
@@ -185,6 +231,8 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
185
231
|
});
|
|
186
232
|
setEmailTouched(false);
|
|
187
233
|
set_legal_accepted({});
|
|
234
|
+
setLocationValues({ country: "", state_province: "", suburb: "" });
|
|
235
|
+
setCustomFieldValues({});
|
|
188
236
|
}
|
|
189
237
|
catch (error) {
|
|
190
238
|
const errorMessage = error instanceof Error ? error.message : t("register.error.failed_retry_message");
|
|
@@ -200,7 +248,18 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
200
248
|
finally {
|
|
201
249
|
setIsSubmitting(false);
|
|
202
250
|
}
|
|
203
|
-
}, [
|
|
251
|
+
}, [
|
|
252
|
+
values,
|
|
253
|
+
passwordRequirements,
|
|
254
|
+
dataClient,
|
|
255
|
+
urlOnLogon,
|
|
256
|
+
legalDocs,
|
|
257
|
+
legal_accepted,
|
|
258
|
+
locationFields,
|
|
259
|
+
locationValues,
|
|
260
|
+
customFieldsSchema,
|
|
261
|
+
customFieldValues,
|
|
262
|
+
]);
|
|
204
263
|
const handleCancel = useCallback(() => {
|
|
205
264
|
const resetValues = buildInitialValues();
|
|
206
265
|
setValues(resetValues);
|
|
@@ -211,6 +270,8 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
211
270
|
});
|
|
212
271
|
setEmailTouched(false);
|
|
213
272
|
set_legal_accepted({});
|
|
273
|
+
setLocationValues({ country: "", state_province: "", suburb: "" });
|
|
274
|
+
setCustomFieldValues({});
|
|
214
275
|
}, []);
|
|
215
276
|
return {
|
|
216
277
|
values,
|
|
@@ -226,5 +287,9 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
226
287
|
handleCancel,
|
|
227
288
|
legal_accepted,
|
|
228
289
|
handleLegalAcceptedChange,
|
|
290
|
+
locationValues,
|
|
291
|
+
handleLocationFieldChange,
|
|
292
|
+
customFieldValues,
|
|
293
|
+
handleCustomFieldChange,
|
|
229
294
|
};
|
|
230
295
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type ButtonPaletteOverrides, type LayoutFieldMapOverrides, type LayoutLabelOverrides, type PasswordRequirementOverrides } from "../shared/config/layout_customization.js";
|
|
2
2
|
import { type LayoutDataClient } from "../shared/data/layout_data_client.js";
|
|
3
3
|
import type { StaticImageData } from "next/image";
|
|
4
|
+
import type { LocationFieldsConfig } from "../../../lib/location_fields_config.server";
|
|
5
|
+
import type { AppUserDataSchema } from "../../../lib/app_user_data_config.server";
|
|
4
6
|
export type OAuthLayoutConfig = {
|
|
5
7
|
/** Enable Google OAuth login */
|
|
6
8
|
enable_google: boolean;
|
|
@@ -39,6 +41,10 @@ export type RegisterLayoutProps<TClient = unknown> = {
|
|
|
39
41
|
oauth?: OAuthLayoutConfig;
|
|
40
42
|
/** Layout mode (default: `"two_column"`). See `LoginLayoutProps.layout` for the full description. */
|
|
41
43
|
layout?: "two_column" | "form_only";
|
|
44
|
+
/** Which indexed location fields to render — see [hazo_auth__custom_fields]. */
|
|
45
|
+
locationFields?: LocationFieldsConfig;
|
|
46
|
+
/** Arbitrary custom fields, reusing the existing app_user_data JSON Schema config. */
|
|
47
|
+
customFieldsSchema?: AppUserDataSchema | null;
|
|
42
48
|
};
|
|
43
|
-
export default function register_layout<TClient>({ image_src, image_alt, image_background_color, field_overrides, labels, button_colors, password_requirements, show_name_field, data_client, alreadyLoggedInMessage, showLogoutButton, showReturnHomeButton, returnHomeButtonLabel, returnHomePath, signInPath, signInLabel, urlOnLogon, oauth, layout, }: RegisterLayoutProps<TClient>): import("react").JSX.Element;
|
|
49
|
+
export default function register_layout<TClient>({ image_src, image_alt, image_background_color, field_overrides, labels, button_colors, password_requirements, show_name_field, data_client, alreadyLoggedInMessage, showLogoutButton, showReturnHomeButton, returnHomeButtonLabel, returnHomePath, signInPath, signInLabel, urlOnLogon, oauth, layout, locationFields, customFieldsSchema, }: RegisterLayoutProps<TClient>): import("react").JSX.Element;
|
|
44
50
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/register/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAClC,MAAM,uCAAuC,CAAC;AAY/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/register/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAClC,MAAM,u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AAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,qGAAqG;IACrG,MAAM,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC;IACpC,gFAAgF;IAChF,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,sFAAsF;IACtF,kBAAkB,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAC/C,CAAC;AAkBF,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,OAAO,EAAE,EAC/C,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,eAAe,EACf,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,eAAsB,EACtB,WAAW,EACX,sBAAsB,EACtB,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqB,EACrB,cAAoB,EACpB,UAA+B,EAC/B,WAAW,EACX,UAAU,EACV,KAAK,EACL,MAAqB,EACrB,cAAc,EACd,kBAAkB,GACnB,EAAE,mBAAmB,CAAC,OAAO,CAAC,+BAwW9B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// file_description: register layout component built atop shared layout utilities
|
|
2
2
|
// section: client_directive
|
|
3
3
|
"use client";
|
|
4
|
-
import { jsx as _jsx,
|
|
4
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
5
|
// section: imports
|
|
6
6
|
import { useState, useEffect } from "react";
|
|
7
7
|
import Link from "next/link";
|
|
@@ -22,6 +22,11 @@ import { use_register_form, } from "./hooks/use_register_form.js";
|
|
|
22
22
|
import { LegalDocCheckboxList } from "../legal/legal_doc_checkbox_list.js";
|
|
23
23
|
import { LegalDocCombinedView } from "../legal/legal_doc_combined_view.js";
|
|
24
24
|
import { useHazoAuthConfig, useAuthT } from "../../../contexts/hazo_auth_provider.js";
|
|
25
|
+
const LOCATION_FIELD_LABELS = {
|
|
26
|
+
country: "register.field.location_country.label",
|
|
27
|
+
state_province: "register.field.location_state_province.label",
|
|
28
|
+
suburb: "register.field.location_suburb.label",
|
|
29
|
+
};
|
|
25
30
|
const ORDERED_FIELDS = [
|
|
26
31
|
REGISTER_FIELD_IDS.NAME,
|
|
27
32
|
REGISTER_FIELD_IDS.EMAIL,
|
|
@@ -29,7 +34,7 @@ const ORDERED_FIELDS = [
|
|
|
29
34
|
REGISTER_FIELD_IDS.CONFIRM_PASSWORD,
|
|
30
35
|
];
|
|
31
36
|
// section: component
|
|
32
|
-
export default function register_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, password_requirements, show_name_field = true, data_client, alreadyLoggedInMessage, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel, returnHomePath = "/", signInPath = "/hazo_auth/login", signInLabel, urlOnLogon, oauth, layout = "two_column", }) {
|
|
37
|
+
export default function register_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, password_requirements, show_name_field = true, data_client, alreadyLoggedInMessage, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel, returnHomePath = "/", signInPath = "/hazo_auth/login", signInLabel, urlOnLogon, oauth, layout = "two_column", locationFields, customFieldsSchema, }) {
|
|
33
38
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
34
39
|
const t = useAuthT();
|
|
35
40
|
const resolvedAlreadyLoggedInMessage = alreadyLoggedInMessage !== null && alreadyLoggedInMessage !== void 0 ? alreadyLoggedInMessage : t("shared.guard.already_logged_in_prop_default");
|
|
@@ -97,7 +102,23 @@ export default function register_layout({ image_src, image_alt, image_background
|
|
|
97
102
|
dataClient: data_client,
|
|
98
103
|
urlOnLogon: effectiveUrlOnLogon,
|
|
99
104
|
legalDocs: legal_docs,
|
|
105
|
+
locationFields,
|
|
106
|
+
customFieldsSchema,
|
|
100
107
|
});
|
|
108
|
+
// Additive, below the fixed name/email/password fields — never merged into
|
|
109
|
+
// REGISTER_FIELD_IDS's closed union (see use_register_form.ts's doc comment).
|
|
110
|
+
const renderLocationAndCustomFields = () => {
|
|
111
|
+
const enabledLocationKeys = ["country", "state_province", "suburb"].filter((key) => locationFields === null || locationFields === void 0 ? void 0 : locationFields[key]);
|
|
112
|
+
const customEntries = customFieldsSchema
|
|
113
|
+
? Object.entries(customFieldsSchema.properties).filter(([, def]) => def.type !== "object")
|
|
114
|
+
: [];
|
|
115
|
+
if (enabledLocationKeys.length === 0 && customEntries.length === 0)
|
|
116
|
+
return null;
|
|
117
|
+
return (_jsxs(_Fragment, { children: [enabledLocationKeys.map((key) => (_jsx(FormFieldWrapper, { fieldId: `register_location_${key}`, label: t(LOCATION_FIELD_LABELS[key]), input: _jsx(Input, { id: `register_location_${key}`, type: "text", value: form.locationValues[key], onChange: (event) => form.handleLocationFieldChange(key, event.target.value), className: "cls_register_layout_field_input" }) }, key))), customEntries.map(([key, def]) => {
|
|
118
|
+
var _a;
|
|
119
|
+
return (_jsx(FormFieldWrapper, { fieldId: `register_custom_${key}`, label: key, input: def.type === "boolean" ? (_jsx("input", { id: `register_custom_${key}`, type: "checkbox", checked: form.customFieldValues[key] === "true", onChange: (event) => form.handleCustomFieldChange(key, event.target.checked ? "true" : "false"), className: "cls_register_layout_custom_field_checkbox" })) : (_jsx(Input, { id: `register_custom_${key}`, type: def.type === "number" ? "number" : "text", value: (_a = form.customFieldValues[key]) !== null && _a !== void 0 ? _a : "", onChange: (event) => form.handleCustomFieldChange(key, event.target.value), className: "cls_register_layout_field_input" })) }, key));
|
|
120
|
+
})] }));
|
|
121
|
+
};
|
|
101
122
|
const renderFields = (formState) => {
|
|
102
123
|
const renderOrder = ORDERED_FIELDS.filter((fieldId) => show_name_field || fieldId !== REGISTER_FIELD_IDS.NAME);
|
|
103
124
|
return renderOrder.map((fieldId) => {
|
|
@@ -124,11 +145,16 @@ export default function register_layout({ image_src, image_alt, image_background
|
|
|
124
145
|
// Form content — used in both layout modes. See `login_layout` for the
|
|
125
146
|
// rationale: keeps the form independent of TwoColumnAuthLayout / AuthPageShell
|
|
126
147
|
// so consumers can compose it into their own brand chrome.
|
|
127
|
-
const mainContent = (_jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), oauthError && (_jsxs("div", { className: "cls_register_layout_oauth_error flex items-center gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700", children: [_jsx(AlertCircle, { className: "h-4 w-4 shrink-0", "aria-hidden": "true" }), _jsx("span", { children: getOAuthErrorMessage(oauthError) })] })), oauthConfig.enable_google && (_jsx("div", { className: "cls_register_layout_oauth_section", children: _jsx(GoogleSignInButton, { label: oauthConfig.google_button_text, callbackUrl: oauthCallbackUrl }) })), oauthConfig.enable_facebook_oauth && (_jsx("div", { className: "cls_register_layout_facebook_section", children: _jsx(FacebookSignInButton, { label: oauthConfig.facebook_button_text || t("shared.oauth.facebook_button_default"), callbackUrl: "/api/hazo_auth/oauth/facebook/callback" }) })), (oauthConfig.enable_google || oauthConfig.enable_facebook_oauth) && oauthConfig.enable_email_password && (_jsx(OAuthDivider, { text: oauthConfig.oauth_divider_text })), oauthConfig.enable_email_password && (_jsxs("form", { className: "cls_register_layout_form_fields flex flex-col gap-5", onSubmit: form.handleSubmit, "aria-label": t("register.aria.form"), children: [renderFields(form), legal_docs.length > 0 && (_jsx("div", { className: "space-y-2", children: legal_display_mode === 'combined' ? (_jsx(LegalDocCombinedView, { docs: legal_docs, accepted: legal_docs.every(doc => form.legal_accepted[doc.key]), onAcceptedChange: (value) => legal_docs.forEach(doc => form.handleLegalAcceptedChange(doc.key, value)) })) : (_jsx(LegalDocCheckboxList, { docs: legal_docs, accepted: form.legal_accepted, onAcceptedChange: form.handleLegalAcceptedChange })) })), _jsx(FormActionButtons, { submitLabel: resolvedLabels.submitButton, cancelLabel: resolvedLabels.cancelButton, buttonPalette: resolvedButtonPalette, isSubmitDisabled: form.isSubmitDisabled, onCancel: form.handleCancel, submitAriaLabel: t("register.aria.submit"), cancelAriaLabel: t("register.aria.cancel") }), _jsxs("div", { className: "cls_register_layout_sign_in_link flex items-center justify-center gap-1 text-sm text-muted-foreground", children: [_jsx("span", { children: t("register.sign_in_prompt") }), _jsx(Link, { href: signInPath, className: "cls_register_layout_sign_in_link_text text-primary underline-offset-4 hover:underline", "aria-label": t("register.aria.sign_in_link"), children: resolvedSignInLabel })] }), form.isSubmitting && (_jsx("div", { className: "cls_register_submitting_indicator text-sm text-slate-600 text-center", children: t("register.submitting_indicator") }))] })), !oauthConfig.enable_email_password && (oauthConfig.enable_google || oauthConfig.enable_facebook_oauth) && (_jsxs("div", { className: "cls_register_layout_sign_in_link mt-4 flex items-center justify-center gap-1 text-sm text-muted-foreground", children: [_jsx("span", { children: t("register.sign_in_prompt") }), _jsx(Link, { href: signInPath, className: "cls_register_layout_sign_in_link_text text-primary underline-offset-4 hover:underline", "aria-label": t("register.aria.sign_in_link"), children: resolvedSignInLabel })] }))] }));
|
|
148
|
+
const mainContent = (_jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), oauthError && (_jsxs("div", { className: "cls_register_layout_oauth_error flex items-center gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700", children: [_jsx(AlertCircle, { className: "h-4 w-4 shrink-0", "aria-hidden": "true" }), _jsx("span", { children: getOAuthErrorMessage(oauthError) })] })), oauthConfig.enable_google && (_jsx("div", { className: "cls_register_layout_oauth_section", children: _jsx(GoogleSignInButton, { label: oauthConfig.google_button_text, callbackUrl: oauthCallbackUrl }) })), oauthConfig.enable_facebook_oauth && (_jsx("div", { className: "cls_register_layout_facebook_section", children: _jsx(FacebookSignInButton, { label: oauthConfig.facebook_button_text || t("shared.oauth.facebook_button_default"), callbackUrl: "/api/hazo_auth/oauth/facebook/callback" }) })), (oauthConfig.enable_google || oauthConfig.enable_facebook_oauth) && oauthConfig.enable_email_password && (_jsx(OAuthDivider, { text: oauthConfig.oauth_divider_text })), oauthConfig.enable_email_password && (_jsxs("form", { className: "cls_register_layout_form_fields flex flex-col gap-5", onSubmit: form.handleSubmit, "aria-label": t("register.aria.form"), children: [renderFields(form), renderLocationAndCustomFields(), legal_docs.length > 0 && (_jsx("div", { className: "space-y-2", children: legal_display_mode === 'combined' ? (_jsx(LegalDocCombinedView, { docs: legal_docs, accepted: legal_docs.every(doc => form.legal_accepted[doc.key]), onAcceptedChange: (value) => legal_docs.forEach(doc => form.handleLegalAcceptedChange(doc.key, value)) })) : (_jsx(LegalDocCheckboxList, { docs: legal_docs, accepted: form.legal_accepted, onAcceptedChange: form.handleLegalAcceptedChange })) })), _jsx(FormActionButtons, { submitLabel: resolvedLabels.submitButton, cancelLabel: resolvedLabels.cancelButton, buttonPalette: resolvedButtonPalette, isSubmitDisabled: form.isSubmitDisabled, onCancel: form.handleCancel, submitAriaLabel: t("register.aria.submit"), cancelAriaLabel: t("register.aria.cancel") }), _jsxs("div", { className: "cls_register_layout_sign_in_link flex items-center justify-center gap-1 text-sm text-muted-foreground", children: [_jsx("span", { children: t("register.sign_in_prompt") }), _jsx(Link, { href: signInPath, className: "cls_register_layout_sign_in_link_text text-primary underline-offset-4 hover:underline", "aria-label": t("register.aria.sign_in_link"), children: resolvedSignInLabel })] }), form.isSubmitting && (_jsx("div", { className: "cls_register_submitting_indicator text-sm text-slate-600 text-center", children: t("register.submitting_indicator") }))] })), !oauthConfig.enable_email_password && (oauthConfig.enable_google || oauthConfig.enable_facebook_oauth) && (_jsxs("div", { className: "cls_register_layout_sign_in_link mt-4 flex items-center justify-center gap-1 text-sm text-muted-foreground", children: [_jsx("span", { children: t("register.sign_in_prompt") }), _jsx(Link, { href: signInPath, className: "cls_register_layout_sign_in_link_text text-primary underline-offset-4 hover:underline", "aria-label": t("register.aria.sign_in_link"), children: resolvedSignInLabel })] }))] }));
|
|
128
149
|
// form_only mode: emit just the form content. See login_layout for the
|
|
129
150
|
// rationale; AlreadyLoggedInGuard is intentionally skipped here.
|
|
151
|
+
// The wrapper below mirrors TwoColumnAuthLayout's own form container
|
|
152
|
+
// (`cls_two_column_auth_layout_form_inner`, `max-w-sm`) — without it the
|
|
153
|
+
// form floats at its natural width inside the consumer's centered flex
|
|
154
|
+
// chrome, drifting right with excess whitespace on the left instead of
|
|
155
|
+
// rendering as a centered, width-constrained column.
|
|
130
156
|
if (layout === "form_only") {
|
|
131
|
-
return mainContent;
|
|
157
|
+
return (_jsx("div", { className: "cls_register_layout_form_only_container mx-auto flex w-full max-w-sm flex-col gap-6", children: mainContent }));
|
|
132
158
|
}
|
|
133
159
|
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: resolvedAlreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: mainContent }) }));
|
|
134
160
|
}
|
|
@@ -9,6 +9,13 @@ export type AlreadyLoggedInGuardProps = {
|
|
|
9
9
|
returnHomeButtonLabel?: string;
|
|
10
10
|
returnHomePath?: string;
|
|
11
11
|
requireEmailVerified?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* When set, skip the "already logged in" message/buttons entirely and
|
|
14
|
+
* `router.replace()` straight to this path (e.g. `/dashboard`). A brief
|
|
15
|
+
* loading placeholder renders while the redirect is in flight. Undefined
|
|
16
|
+
* (default) preserves the existing message + logout/return-home UX.
|
|
17
|
+
*/
|
|
18
|
+
redirectPath?: string;
|
|
12
19
|
children: React.ReactNode;
|
|
13
20
|
};
|
|
14
21
|
/**
|
|
@@ -17,5 +24,5 @@ export type AlreadyLoggedInGuardProps = {
|
|
|
17
24
|
* @param props - Component props including layout config and message customization
|
|
18
25
|
* @returns Either the "already logged in" UI or the children
|
|
19
26
|
*/
|
|
20
|
-
export declare function AlreadyLoggedInGuard({ image_src, image_alt, image_background_color, message, showLogoutButton, showReturnHomeButton, returnHomeButtonLabel, returnHomePath, requireEmailVerified, children, }: AlreadyLoggedInGuardProps): import("react").JSX.Element;
|
|
27
|
+
export declare function AlreadyLoggedInGuard({ image_src, image_alt, image_background_color, message, showLogoutButton, showReturnHomeButton, returnHomeButtonLabel, returnHomePath, requireEmailVerified, redirectPath, children, }: AlreadyLoggedInGuardProps): import("react").JSX.Element;
|
|
21
28
|
//# sourceMappingURL=already_logged_in_guard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"already_logged_in_guard.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/shared/components/already_logged_in_guard.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"already_logged_in_guard.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/shared/components/already_logged_in_guard.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlD,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAGF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,OAAO,EACP,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqB,EACrB,cAAoB,EACpB,oBAA4B,EAC5B,YAAY,EACZ,QAAQ,GACT,EAAE,yBAAyB,+BAwE3B"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
"use client";
|
|
4
4
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
5
5
|
// section: imports
|
|
6
|
+
import { useEffect } from "react";
|
|
6
7
|
import { use_auth_status } from "../hooks/use_auth_status.js";
|
|
7
8
|
import { LogoutButton } from "./logout_button.js";
|
|
8
9
|
import { Button } from "../../../ui/button.js";
|
|
@@ -17,7 +18,7 @@ import { useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
|
17
18
|
* @param props - Component props including layout config and message customization
|
|
18
19
|
* @returns Either the "already logged in" UI or the children
|
|
19
20
|
*/
|
|
20
|
-
export function AlreadyLoggedInGuard({ image_src, image_alt, image_background_color = "#f1f5f9", message, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel, returnHomePath = "/", requireEmailVerified = false, children, }) {
|
|
21
|
+
export function AlreadyLoggedInGuard({ image_src, image_alt, image_background_color = "#f1f5f9", message, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel, returnHomePath = "/", requireEmailVerified = false, redirectPath, children, }) {
|
|
21
22
|
const t = useAuthT();
|
|
22
23
|
const resolvedMessage = message !== null && message !== void 0 ? message : t("shared.guard.already_logged_in_message");
|
|
23
24
|
const resolvedReturnHomeButtonLabel = returnHomeButtonLabel !== null && returnHomeButtonLabel !== void 0 ? returnHomeButtonLabel : t("shared.guard.return_home_default");
|
|
@@ -29,6 +30,19 @@ export function AlreadyLoggedInGuard({ image_src, image_alt, image_background_co
|
|
|
29
30
|
const shouldShowAlreadyLoggedIn = authStatus.authenticated &&
|
|
30
31
|
!authStatus.loading &&
|
|
31
32
|
(!requireEmailVerified || authStatus.email_verified === true);
|
|
33
|
+
const shouldRedirect = shouldShowAlreadyLoggedIn && !!redirectPath;
|
|
34
|
+
// Fire the redirect as a side effect (not during render) once we know the
|
|
35
|
+
// user is authenticated. `router.replace` (not `push`) so the auth page
|
|
36
|
+
// never lands in browser history — hitting Back won't bounce the user
|
|
37
|
+
// straight back to it.
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (shouldRedirect && redirectPath) {
|
|
40
|
+
router.replace(redirectPath);
|
|
41
|
+
}
|
|
42
|
+
}, [shouldRedirect, redirectPath, router]);
|
|
43
|
+
if (shouldRedirect) {
|
|
44
|
+
return (_jsx("div", { className: "cls_already_logged_in_guard_redirecting flex items-center justify-center min-h-screen", children: _jsx("div", { className: "text-slate-600 animate-pulse", children: t("shared.guard.loading") }) }));
|
|
45
|
+
}
|
|
32
46
|
if (shouldShowAlreadyLoggedIn) {
|
|
33
47
|
return (_jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs("div", { className: "cls_already_logged_in_guard flex flex-col items-center justify-center gap-4 p-8 text-center", children: [_jsx("p", { className: "cls_already_logged_in_guard_message text-lg font-medium text-slate-900", children: resolvedMessage }), _jsxs("div", { className: "cls_already_logged_in_guard_actions flex flex-col gap-3 items-center mt-4", children: [showLogoutButton && (_jsx(LogoutButton, { className: "cls_already_logged_in_guard_logout_button", variant: "default" })), showReturnHomeButton && (_jsxs(Button, { onClick: () => router.push(returnHomePath), variant: "outline", className: "cls_already_logged_in_guard_return_home_button", "aria-label": resolvedReturnHomeButtonLabel, children: [_jsx(Home, { className: "h-4 w-4 mr-2", "aria-hidden": "true" }), resolvedReturnHomeButtonLabel] }))] })] }) }));
|
|
34
48
|
}
|
|
@@ -11,6 +11,9 @@ export type AuthStatusData = {
|
|
|
11
11
|
image?: string;
|
|
12
12
|
profile_source?: "upload" | "library" | "gravatar" | "custom";
|
|
13
13
|
preferred_locale?: string | null;
|
|
14
|
+
country?: string | null;
|
|
15
|
+
state_province?: string | null;
|
|
16
|
+
suburb?: string | null;
|
|
14
17
|
permissions?: string[];
|
|
15
18
|
permission_ok?: boolean;
|
|
16
19
|
missing_permissions?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_auth_status.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/shared/hooks/use_auth_status.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,cAAc,GAAG;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IAE9D,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"use_auth_status.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/shared/hooks/use_auth_status.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,cAAc,GAAG;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IAE9D,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG;IACxC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAMF;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAIlD;AAGD,wBAAgB,eAAe,IAAI,UAAU,CA+E5C"}
|
|
@@ -23,7 +23,7 @@ export function use_auth_status() {
|
|
|
23
23
|
loading: true,
|
|
24
24
|
});
|
|
25
25
|
const checkAuth = useCallback(async () => {
|
|
26
|
-
var _a, _b;
|
|
26
|
+
var _a, _b, _c, _d, _e;
|
|
27
27
|
setAuthStatus((prev) => (Object.assign(Object.assign({}, prev), { loading: true })));
|
|
28
28
|
try {
|
|
29
29
|
const response = await fetch(`${apiBasePath}/me`, {
|
|
@@ -46,8 +46,11 @@ export function use_auth_status() {
|
|
|
46
46
|
image: data.image,
|
|
47
47
|
profile_source: data.profile_source,
|
|
48
48
|
preferred_locale: (_a = data.preferred_locale) !== null && _a !== void 0 ? _a : null,
|
|
49
|
+
country: (_b = data.country) !== null && _b !== void 0 ? _b : null,
|
|
50
|
+
state_province: (_c = data.state_province) !== null && _c !== void 0 ? _c : null,
|
|
51
|
+
suburb: (_d = data.suburb) !== null && _d !== void 0 ? _d : null,
|
|
49
52
|
permissions: data.permissions || [],
|
|
50
|
-
permission_ok: (
|
|
53
|
+
permission_ok: (_e = data.permission_ok) !== null && _e !== void 0 ? _e : true,
|
|
51
54
|
missing_permissions: data.missing_permissions,
|
|
52
55
|
// OAuth-related fields
|
|
53
56
|
auth_providers: data.auth_providers,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const buttonVariants: (props?: ({
|
|
4
|
-
variant?: "
|
|
4
|
+
variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
5
5
|
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
@@ -7,6 +7,14 @@ export type AlreadyLoggedInConfig = {
|
|
|
7
7
|
/** Undefined when not configured — components fall back to their own i18n `t()` default. */
|
|
8
8
|
returnHomeButtonLabel: string | undefined;
|
|
9
9
|
returnHomePath: string;
|
|
10
|
+
/**
|
|
11
|
+
* When set, an already-authenticated user who lands on an auth page (login,
|
|
12
|
+
* register, forgot/reset password, email verification) is sent straight to
|
|
13
|
+
* this path instead of seeing the "already logged in" message + buttons.
|
|
14
|
+
* Undefined when not configured (default) — preserves the existing
|
|
15
|
+
* message/logout/return-home UX unchanged.
|
|
16
|
+
*/
|
|
17
|
+
redirectPath: string | undefined;
|
|
10
18
|
};
|
|
11
19
|
/**
|
|
12
20
|
* Reads already logged in configuration from hazo_auth_config.ini file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"already_logged_in_config.server.d.ts","sourceRoot":"","sources":["../../src/lib/already_logged_in_config.server.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAMrB,MAAM,MAAM,qBAAqB,GAAG;IAClC,4FAA4F;IAC5F,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,4FAA4F;IAC5F,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,cAAc,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"already_logged_in_config.server.d.ts","sourceRoot":"","sources":["../../src/lib/already_logged_in_config.server.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAMrB,MAAM,MAAM,qBAAqB,GAAG;IAClC,4FAA4F;IAC5F,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,4FAA4F;IAC5F,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,cAAc,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC,CAAC;AAGF;;;;GAIG;AACH,wBAAgB,4BAA4B,IAAI,qBAAqB,CAgCpE"}
|
|
@@ -23,11 +23,15 @@ export function get_already_logged_in_config() {
|
|
|
23
23
|
const returnHomeButtonLabel = get_config_value_optional(section, "return_home_button_label");
|
|
24
24
|
// Read return home path (defaults to "/")
|
|
25
25
|
const returnHomePath = get_config_value(section, "return_home_path", "/");
|
|
26
|
+
// Read redirect path — undefined when not configured, so the guard keeps
|
|
27
|
+
// showing the message + buttons (back-compat default, opt-in feature).
|
|
28
|
+
const redirectPath = get_config_value_optional(section, "redirect_path");
|
|
26
29
|
return {
|
|
27
30
|
message,
|
|
28
31
|
showLogoutButton,
|
|
29
32
|
showReturnHomeButton,
|
|
30
33
|
returnHomeButtonLabel,
|
|
31
34
|
returnHomePath,
|
|
35
|
+
redirectPath,
|
|
32
36
|
};
|
|
33
37
|
}
|
|
@@ -12,6 +12,9 @@ export type HazoAuthUser = {
|
|
|
12
12
|
app_user_data: Record<string, unknown> | null;
|
|
13
13
|
legal_acceptance: LegalAcceptanceMap | null;
|
|
14
14
|
preferred_locale: string | null;
|
|
15
|
+
country: string | null;
|
|
16
|
+
state_province: string | null;
|
|
17
|
+
suburb: string | null;
|
|
15
18
|
};
|
|
16
19
|
/**
|
|
17
20
|
* Scope access information returned when scope checking is used
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth_types.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/auth_types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEnC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAE9C,gBAAgB,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAG5C,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"auth_types.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/auth_types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAA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AE,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,CAAC;AAEN;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,GAAG;IACxD,aAAa,EAAE,IAAI,CAAC;IACpB,YAAY,EAAE,kBAAkB,CAAC;CAClC,CAAC;AAIF;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;aAGpB,IAAI,EAAE,MAAM;aACZ,WAAW,EAAE,MAAM;gBAFnC,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM;CAKtC;AAED;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,aAAa;gBAChD,OAAO,GAAE,MAAkC;CAIxD;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,aAAa;aAGlC,WAAW,EAAE,YAAY,EAAE;gBAD3C,OAAO,GAAE,MAAkC,EAC3B,WAAW,GAAE,YAAY,EAAO;CAKnD;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,aAAa;aAEtC,QAAQ,EAAE,MAAM;aAChB,WAAW,EAAE,YAAY,EAAE;gBAD3B,QAAQ,EAAE,MAAM,EAChB,WAAW,GAAE,YAAY,EAAO;CAKnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hazo_get_auth.server.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/hazo_get_auth.server.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1C,OAAO,KAAK,EACV,cAAc,EAEd,eAAe,EAGhB,MAAM,cAAc,CAAC;AAgEtB;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAU1D;
|
|
1
|
+
{"version":3,"file":"hazo_get_auth.server.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/hazo_get_auth.server.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1C,OAAO,KAAK,EACV,cAAc,EAEd,eAAe,EAGhB,MAAM,cAAc,CAAC;AAgEtB;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAU1D;AAgTD;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,cAAc,CAAC,CA+NzB"}
|
|
@@ -154,6 +154,9 @@ async function fetch_user_data_from_db(user_id) {
|
|
|
154
154
|
app_user_data: parse_app_user_data(user_db.app_user_data),
|
|
155
155
|
legal_acceptance: parse_legal_acceptance(user_db.legal_acceptance),
|
|
156
156
|
preferred_locale: user_db.preferred_locale || null,
|
|
157
|
+
country: user_db.country || null,
|
|
158
|
+
state_province: user_db.state_province || null,
|
|
159
|
+
suburb: user_db.suburb || null,
|
|
157
160
|
};
|
|
158
161
|
// v5.x: Fetch user's roles from hazo_user_scopes (scope-based role assignments)
|
|
159
162
|
// Each scope assignment has a role_id (string UUID)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
export type LocationFieldsConfig = {
|
|
3
|
+
country: boolean;
|
|
4
|
+
state_province: boolean;
|
|
5
|
+
suburb: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Reads the indexed location field toggles (country / state_province / suburb)
|
|
9
|
+
* from `[hazo_auth__custom_fields]` in hazo_auth_config.ini. All default to
|
|
10
|
+
* `false` — registration is unchanged for apps that don't opt in. These three
|
|
11
|
+
* columns are indexed (migration 025) for cohort benchmarking (GROUP BY
|
|
12
|
+
* country, state_province); arbitrary free-form fields go through the
|
|
13
|
+
* existing app_user_data schema (`get_app_user_data_schema()`) instead.
|
|
14
|
+
* @returns Which location fields are enabled
|
|
15
|
+
*/
|
|
16
|
+
export declare function get_location_fields_config(): LocationFieldsConfig;
|
|
17
|
+
/**
|
|
18
|
+
* True if at least one location field is enabled — lets a consumer skip
|
|
19
|
+
* rendering an empty "Location" section entirely.
|
|
20
|
+
*/
|
|
21
|
+
export declare function is_any_location_field_enabled(config: LocationFieldsConfig): boolean;
|
|
22
|
+
//# sourceMappingURL=location_fields_config.server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"location_fields_config.server.d.ts","sourceRoot":"","sources":["../../src/lib/location_fields_config.server.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AASrB,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAGF;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,IAAI,oBAAoB,CAMjE;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAEnF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// file_description: server-only helper to read location field toggles from hazo_auth_config.ini
|
|
2
|
+
// section: server-only-guard
|
|
3
|
+
import "server-only";
|
|
4
|
+
// section: imports
|
|
5
|
+
import { get_config_boolean } from "./config/config_loader.server.js";
|
|
6
|
+
// section: constants
|
|
7
|
+
const SECTION_NAME = "hazo_auth__custom_fields";
|
|
8
|
+
// section: helpers
|
|
9
|
+
/**
|
|
10
|
+
* Reads the indexed location field toggles (country / state_province / suburb)
|
|
11
|
+
* from `[hazo_auth__custom_fields]` in hazo_auth_config.ini. All default to
|
|
12
|
+
* `false` — registration is unchanged for apps that don't opt in. These three
|
|
13
|
+
* columns are indexed (migration 025) for cohort benchmarking (GROUP BY
|
|
14
|
+
* country, state_province); arbitrary free-form fields go through the
|
|
15
|
+
* existing app_user_data schema (`get_app_user_data_schema()`) instead.
|
|
16
|
+
* @returns Which location fields are enabled
|
|
17
|
+
*/
|
|
18
|
+
export function get_location_fields_config() {
|
|
19
|
+
return {
|
|
20
|
+
country: get_config_boolean(SECTION_NAME, "location_country", false),
|
|
21
|
+
state_province: get_config_boolean(SECTION_NAME, "location_state_province", false),
|
|
22
|
+
suburb: get_config_boolean(SECTION_NAME, "location_suburb", false),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* True if at least one location field is enabled — lets a consumer skip
|
|
27
|
+
* rendering an empty "Location" section entirely.
|
|
28
|
+
*/
|
|
29
|
+
export function is_any_location_field_enabled(config) {
|
|
30
|
+
return config.country || config.state_province || config.suburb;
|
|
31
|
+
}
|
|
@@ -9,6 +9,8 @@ export type LoginConfig = {
|
|
|
9
9
|
showReturnHomeButton: boolean;
|
|
10
10
|
returnHomeButtonLabel: string | undefined;
|
|
11
11
|
returnHomePath: string;
|
|
12
|
+
/** See `AlreadyLoggedInConfig.redirectPath` — undefined unless `[hazo_auth__already_logged_in] redirect_path` is set. */
|
|
13
|
+
alreadyLoggedInRedirectPath: string | undefined;
|
|
12
14
|
forgotPasswordPath: string;
|
|
13
15
|
/** Undefined when not configured — falls back to `t("login.forgot_password_link_default")`. "" hides the link. */
|
|
14
16
|
forgotPasswordLabel: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login_config.server.d.ts","sourceRoot":"","sources":["../../src/lib/login_config.server.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AASrB,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAM3E,MAAM,MAAM,WAAW,GAAG;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,8GAA8G;IAC9G,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,sBAAsB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,gBAAgB,EAAE,OAAO,CAAC;IAC1B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,qBAAqB,EAAE,MAAM,GAAG,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,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,0BAA0B;IAC1B,KAAK,EAAE,WAAW,CAAC;CACpB,CAAC;AAGF;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,WAAW,CAyE9C"}
|
|
@@ -51,6 +51,7 @@ export function get_login_config() {
|
|
|
51
51
|
showReturnHomeButton: alreadyLoggedInConfig.showReturnHomeButton,
|
|
52
52
|
returnHomeButtonLabel: alreadyLoggedInConfig.returnHomeButtonLabel,
|
|
53
53
|
returnHomePath: alreadyLoggedInConfig.returnHomePath,
|
|
54
|
+
alreadyLoggedInRedirectPath: alreadyLoggedInConfig.redirectPath,
|
|
54
55
|
forgotPasswordPath,
|
|
55
56
|
forgotPasswordLabel,
|
|
56
57
|
createAccountPath,
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import "server-only";
|
|
2
|
+
import { type LocationFieldsConfig } from "./location_fields_config.server.js";
|
|
2
3
|
export type MySettingsConfig = {
|
|
3
4
|
userFields: {
|
|
4
5
|
show_name_field: boolean;
|
|
5
6
|
show_email_field: boolean;
|
|
6
7
|
show_password_field: boolean;
|
|
7
8
|
};
|
|
9
|
+
/** Which indexed location fields to show as an editable "Location" card —
|
|
10
|
+
* see [hazo_auth__custom_fields] in hazo_auth_config.ini. */
|
|
11
|
+
locationFields: LocationFieldsConfig;
|
|
8
12
|
passwordRequirements: {
|
|
9
13
|
minimum_length: number;
|
|
10
14
|
require_uppercase: boolean;
|