hazo_auth 10.15.0 → 10.17.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.
Files changed (31) hide show
  1. package/cli-src/lib/auth/auth_types.ts +3 -0
  2. package/cli-src/lib/auth/hazo_get_auth.server.ts +1 -0
  3. package/cli-src/lib/services/oauth_service.ts +17 -2
  4. package/cli-src/lib/services/user_update_service.ts +9 -0
  5. package/dist/components/layouts/my_settings/components/language_picker_section.d.ts +23 -0
  6. package/dist/components/layouts/my_settings/components/language_picker_section.d.ts.map +1 -0
  7. package/dist/components/layouts/my_settings/components/language_picker_section.js +40 -0
  8. package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts +2 -0
  9. package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts.map +1 -1
  10. package/dist/components/layouts/my_settings/hooks/use_my_settings.js +31 -0
  11. package/dist/components/layouts/my_settings/index.d.ts +9 -1
  12. package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
  13. package/dist/components/layouts/my_settings/index.js +3 -2
  14. package/dist/components/layouts/shared/hooks/use_auth_status.d.ts +1 -0
  15. package/dist/components/layouts/shared/hooks/use_auth_status.d.ts.map +1 -1
  16. package/dist/components/layouts/shared/hooks/use_auth_status.js +3 -2
  17. package/dist/lib/auth/auth_types.d.ts +1 -0
  18. package/dist/lib/auth/auth_types.d.ts.map +1 -1
  19. package/dist/lib/auth/hazo_get_auth.server.d.ts.map +1 -1
  20. package/dist/lib/auth/hazo_get_auth.server.js +1 -0
  21. package/dist/lib/services/oauth_service.d.ts.map +1 -1
  22. package/dist/lib/services/oauth_service.js +13 -6
  23. package/dist/lib/services/user_update_service.d.ts +1 -0
  24. package/dist/lib/services/user_update_service.d.ts.map +1 -1
  25. package/dist/lib/services/user_update_service.js +4 -0
  26. package/dist/server/routes/library_photos.d.ts +2 -2
  27. package/dist/server/routes/me.d.ts.map +1 -1
  28. package/dist/server/routes/me.js +3 -1
  29. package/dist/server/routes/update_user.d.ts.map +1 -1
  30. package/dist/server/routes/update_user.js +33 -3
  31. package/package.json +17 -17
@@ -16,6 +16,9 @@ export type HazoAuthUser = {
16
16
  app_user_data: Record<string, unknown> | null;
17
17
  // Legal document acceptance map (JSON object stored in database)
18
18
  legal_acceptance: LegalAcceptanceMap | null;
19
+ // User's explicit locale preference (BCP 47 tag, e.g. "en", "pt-BR"). NULL means
20
+ // no preference set — callers fall back to detection (Accept-Language, app default).
21
+ preferred_locale: string | null;
19
22
  };
20
23
 
21
24
  /**
@@ -206,6 +206,7 @@ async function fetch_user_data_from_db(user_id: string): Promise<{
206
206
  managed_by_user_id: (user_db.managed_by_user_id as string | undefined) || null,
207
207
  app_user_data: parse_app_user_data(user_db.app_user_data),
208
208
  legal_acceptance: parse_legal_acceptance(user_db.legal_acceptance),
209
+ preferred_locale: (user_db.preferred_locale as string | null | undefined) || null,
209
210
  };
210
211
 
211
212
  // v5.x: Fetch user's roles from hazo_user_scopes (scope-based role assignments)
@@ -87,10 +87,16 @@ export async function handle_google_oauth_login(
87
87
  if (Array.isArray(users_by_google_id) && users_by_google_id.length > 0) {
88
88
  const user = users_by_google_id[0];
89
89
 
90
- // Update last_logon timestamp
90
+ // Update last_logon timestamp. Google is the source of truth for this
91
+ // user's avatar on this path (they just authenticated via Google, and
92
+ // google_id already matches), so refresh profile_picture_url whenever
93
+ // Google provides a truthy value — regardless of what's already stored.
94
+ // This handles CDN URL rotation, unlike Step 2/3's first-time-population
95
+ // guard (`!user.profile_picture_url && profile_picture_url`).
91
96
  await users_service.updateById(user.id, {
92
97
  last_logon: now,
93
98
  changed_at: now,
99
+ ...(profile_picture_url ? { profile_picture_url, profile_source: "custom" } : {}),
94
100
  });
95
101
 
96
102
  logger.info("oauth_service_google_login_existing_google_user", {
@@ -270,7 +276,16 @@ export async function handle_facebook_oauth_login(
270
276
  const users_by_fb_id = await users_service.findBy({ facebook_id });
271
277
  if (Array.isArray(users_by_fb_id) && users_by_fb_id.length > 0) {
272
278
  const user = users_by_fb_id[0];
273
- await users_service.updateById(user.id, { last_logon: now, changed_at: now });
279
+ // Facebook is the source of truth for this user's avatar on this path
280
+ // (they just authenticated via Facebook, and facebook_id already
281
+ // matches), so refresh profile_picture_url whenever Facebook provides a
282
+ // truthy value — regardless of what's already stored. This handles CDN
283
+ // URL rotation, unlike Step 2/3's first-time-population guard.
284
+ await users_service.updateById(user.id, {
285
+ last_logon: now,
286
+ changed_at: now,
287
+ ...(profile_picture_url ? { profile_picture_url, profile_source: "custom" } : {}),
288
+ });
274
289
  logger.info("oauth_service_facebook_login_existing_fb_user", {
275
290
  filename: "oauth_service.ts",
276
291
  user_id: user.id,
@@ -13,6 +13,10 @@ export type UserUpdateData = {
13
13
  email?: string;
14
14
  profile_picture_url?: string;
15
15
  profile_source?: ProfilePictureSourceUI;
16
+ // BCP 47 locale tag (e.g. "en", "pt-BR"), or null to explicitly clear the preference.
17
+ // Undefined means "leave unchanged" — the caller is expected to have already validated
18
+ // the value (see src/server/routes/update_user.ts).
19
+ preferred_locale?: string | null;
16
20
  };
17
21
 
18
22
  export type UserUpdateResult = {
@@ -106,6 +110,11 @@ export async function update_user_profile(
106
110
  update_data.profile_source = map_ui_source_to_db(data.profile_source);
107
111
  }
108
112
 
113
+ if (data.preferred_locale !== undefined) {
114
+ // null explicitly clears the preference (falls back to detection elsewhere)
115
+ update_data.preferred_locale = data.preferred_locale;
116
+ }
117
+
109
118
  // If email changed, set email_verified to false
110
119
  if (email_changed) {
111
120
  update_data.email_verified = false;
@@ -0,0 +1,23 @@
1
+ export type AvailableLocale = {
2
+ code: string;
3
+ label: string;
4
+ };
5
+ export type LanguagePickerSectionProps = {
6
+ /** List of locales the consuming app supports. Field is hidden unless length >= 2. */
7
+ availableLocales?: AvailableLocale[];
8
+ /** User's current preferred_locale value (may be null/undefined if unset). */
9
+ currentLocale?: string | null;
10
+ /** Called with the new locale code when the user picks a different value. */
11
+ onLocaleChange: (localeCode: string) => Promise<void>;
12
+ disabled?: boolean;
13
+ label?: string;
14
+ placeholder?: string;
15
+ };
16
+ /**
17
+ * Renders a Select for choosing a preferred locale.
18
+ * Returns null when fewer than 2 locales are available (single-locale apps see no change).
19
+ * @param props - Component props
20
+ * @returns Language picker field, or null when not applicable
21
+ */
22
+ export declare function LanguagePickerSection({ availableLocales, currentLocale, onLocaleChange, disabled, label, placeholder, }: LanguagePickerSectionProps): import("react").JSX.Element | null;
23
+ //# sourceMappingURL=language_picker_section.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language_picker_section.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/language_picker_section.tsx"],"names":[],"mappings":"AAkBA,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,0BAA0B,GAAG;IACvC,sFAAsF;IACtF,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC,8EAA8E;IAC9E,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,6EAA6E;IAC7E,cAAc,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAGF;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,QAAgB,EAChB,KAAkB,EAClB,WAAiC,GAClC,EAAE,0BAA0B,sCAmD5B"}
@@ -0,0 +1,40 @@
1
+ // file_description: language picker field for My Settings — Profile Information section.
2
+ // i18n prerequisite (FR-028). Renders nothing unless the consuming app supplies 2+
3
+ // available locales; single-locale consumers see no change from current behavior.
4
+ // section: client_directive
5
+ "use client";
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
+ // section: imports
8
+ import { useState } from "react";
9
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "../../../ui/select.js";
10
+ import { FormFieldWrapper } from "../../shared/components/form_field_wrapper.js";
11
+ // section: component
12
+ /**
13
+ * Renders a Select for choosing a preferred locale.
14
+ * Returns null when fewer than 2 locales are available (single-locale apps see no change).
15
+ * @param props - Component props
16
+ * @returns Language picker field, or null when not applicable
17
+ */
18
+ export function LanguagePickerSection({ availableLocales, currentLocale, onLocaleChange, disabled = false, label = "Language", placeholder = "Select a language", }) {
19
+ const [saving, setSaving] = useState(false);
20
+ if (!availableLocales || availableLocales.length < 2) {
21
+ return null;
22
+ }
23
+ const handleValueChange = async (value) => {
24
+ if (value === currentLocale)
25
+ return;
26
+ setSaving(true);
27
+ try {
28
+ await onLocaleChange(value);
29
+ }
30
+ catch (_a) {
31
+ // onLocaleChange already surfaces the error (toast); nothing further to do here.
32
+ }
33
+ finally {
34
+ setSaving(false);
35
+ }
36
+ };
37
+ return (_jsx("div", { className: "cls_language_picker_section", children: _jsx(FormFieldWrapper, { fieldId: "preferred-locale", label: label, input: _jsxs(Select, { value: currentLocale !== null && currentLocale !== void 0 ? currentLocale : undefined, onValueChange: (value) => {
38
+ void handleValueChange(value);
39
+ }, disabled: disabled || saving, children: [_jsx(SelectTrigger, { id: "preferred-locale", className: "cls_language_picker_section_trigger", "aria-label": label, children: _jsx(SelectValue, { placeholder: placeholder }) }), _jsx(SelectContent, { children: availableLocales.map((locale) => (_jsx(SelectItem, { value: locale.code, children: locale.label }, locale.code))) })] }) }) }));
40
+ }
@@ -17,6 +17,7 @@ export type UseMySettingsResult = {
17
17
  email: string;
18
18
  profilePictureUrl?: string;
19
19
  profileSource?: "upload" | "library" | "gravatar" | "custom";
20
+ preferredLocale?: string | null;
20
21
  lastLogon?: string;
21
22
  loading: boolean;
22
23
  authProviders?: string;
@@ -34,6 +35,7 @@ export type UseMySettingsResult = {
34
35
  handleProfilePictureRemove: () => Promise<void>;
35
36
  handleNameSave: (value: string) => Promise<void>;
36
37
  handleEmailSave: (value: string) => Promise<void>;
38
+ handlePreferredLocaleSave: (localeCode: string) => Promise<void>;
37
39
  refreshUserData: () => Promise<void>;
38
40
  };
39
41
  export type UseMySettingsParams = {
@@ -1 +1 @@
1
- {"version":3,"file":"use_my_settings.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/hooks/use_my_settings.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAI3F,MAAM,MAAM,cAAc,GAAG;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,sBAAsB,EAAE,OAAO,CAAC;IAChC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,sBAAsB,EAAE,OAAO,CAAC;IAChC,MAAM,EAAE;QACN,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAChC,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAEhC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IAGjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAG1B,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,yBAAyB,EAAE,CAAC,KAAK,EAAE,iBAAiB,GAAG,aAAa,GAAG,iBAAiB,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjH,wBAAwB,EAAE,CAAC,KAAK,EAAE,iBAAiB,GAAG,aAAa,GAAG,iBAAiB,KAAK,IAAI,CAAC;IACjG,kBAAkB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,sBAAsB,EAAE,OAAO,CAAC;IAGhC,wBAAwB,EAAE,OAAO,CAAC;IAClC,wBAAwB,EAAE,MAAM,IAAI,CAAC;IACrC,+BAA+B,EAAE,MAAM,IAAI,CAAC;IAC5C,wBAAwB,EAAE,CAAC,iBAAiB,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzH,0BAA0B,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAGhD,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAGlD,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,oBAAoB,EAAE,0BAA0B,CAAC;CAClD,CAAC;AA4BF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,EAC9B,oBAAoB,GACrB,EAAE,mBAAmB,GAAG,mBAAmB,CAqX3C"}
1
+ {"version":3,"file":"use_my_settings.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/hooks/use_my_settings.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAI3F,MAAM,MAAM,cAAc,GAAG;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,sBAAsB,EAAE,OAAO,CAAC;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AC,CAAC;IACzH,0BAA0B,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAGhD,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,yBAAyB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAGjE,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,oBAAoB,EAAE,0BAA0B,CAAC;CAClD,CAAC;AA4BF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,EAC9B,oBAAoB,GACrB,EAAE,mBAAmB,GAAG,mBAAmB,CAuZ3C"}
@@ -54,6 +54,7 @@ export function use_my_settings({ passwordRequirements, }) {
54
54
  const email = authStatus.email || "";
55
55
  const profilePictureUrl = authStatus.profile_picture_url;
56
56
  const profileSource = authStatus.profile_source;
57
+ const preferredLocale = authStatus.preferred_locale;
57
58
  const lastLogon = authStatus.last_logon;
58
59
  const loading = authStatus.loading;
59
60
  // OAuth-related data
@@ -139,6 +140,34 @@ export function use_my_settings({ passwordRequirements, }) {
139
140
  throw error;
140
141
  }
141
142
  }, [refreshUserData]);
143
+ /**
144
+ * Updates the user's preferred locale (BCP 47 tag, e.g. "en", "pt-BR")
145
+ */
146
+ const handlePreferredLocaleSave = useCallback(async (localeCode) => {
147
+ try {
148
+ const response = await fetch(`${apiBasePath}/update_user`, {
149
+ method: "PATCH",
150
+ headers: {
151
+ "Content-Type": "application/json",
152
+ },
153
+ credentials: "include",
154
+ body: JSON.stringify({ preferred_locale: localeCode }),
155
+ });
156
+ const data = await response.json();
157
+ if (!response.ok || !data.success) {
158
+ const errorMessage = data.error || "Failed to update language preference";
159
+ toast.error(errorMessage);
160
+ throw new Error(errorMessage);
161
+ }
162
+ toast.success("Language preference updated");
163
+ await refreshUserData();
164
+ }
165
+ catch (error) {
166
+ const errorMessage = error instanceof Error ? error.message : "Failed to update language preference";
167
+ toast.error(errorMessage);
168
+ throw error;
169
+ }
170
+ }, [apiBasePath, refreshUserData]);
142
171
  /**
143
172
  * Validates password requirements
144
173
  */
@@ -341,6 +370,7 @@ export function use_my_settings({ passwordRequirements, }) {
341
370
  email,
342
371
  profilePictureUrl,
343
372
  profileSource,
373
+ preferredLocale,
344
374
  lastLogon,
345
375
  loading,
346
376
  // OAuth-related data
@@ -360,6 +390,7 @@ export function use_my_settings({ passwordRequirements, }) {
360
390
  handleProfilePictureRemove,
361
391
  handleNameSave,
362
392
  handleEmailSave,
393
+ handlePreferredLocaleSave,
363
394
  refreshUserData,
364
395
  };
365
396
  }
@@ -1,3 +1,4 @@
1
+ import { type AvailableLocale } from "./components/language_picker_section.js";
1
2
  import { type MySettingsLabelOverrides } from "./config/my_settings_field_config.js";
2
3
  import type { PasswordRequirementOptions, ButtonPaletteOverrides } from "../shared/config/layout_customization";
3
4
  export type MySettingsLayoutProps = {
@@ -22,6 +23,13 @@ export type MySettingsLayoutProps = {
22
23
  unauthorizedMessage?: string;
23
24
  loginButtonLabel?: string;
24
25
  loginPath?: string;
26
+ /**
27
+ * Locales the consuming app supports, e.g. [{ code: "en", label: "English" },
28
+ * { code: "pt-BR", label: "Português (Brasil)" }]. The language picker only
29
+ * renders when 2 or more entries are supplied — single-locale consumers are
30
+ * unaffected (no field, no behavior change).
31
+ */
32
+ availableLocales?: AvailableLocale[];
25
33
  /**
26
34
  * Whether the Danger Zone (account deletion) section is shown.
27
35
  * Mirrors the `enable_account_deletion` config flag; defaults to off (opt-in).
@@ -66,5 +74,5 @@ export type MySettingsLayoutProps = {
66
74
  * @param props - Component props including labels, button colors, password requirements, etc.
67
75
  * @returns My settings layout component
68
76
  */
69
- export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage, loginButtonLabel, loginPath, enableAccountDeletion, heading, subHeading, profilePhotoLabel, profilePhotoRecommendation, uploadPhotoButtonLabel, removePhotoButtonLabel, profileInformationLabel, passwordLabel, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, messages, uiSizes, fileTypes, }: MySettingsLayoutProps): import("react").JSX.Element;
77
+ export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage, loginButtonLabel, loginPath, availableLocales, enableAccountDeletion, heading, subHeading, profilePhotoLabel, profilePhotoRecommendation, uploadPhotoButtonLabel, removePhotoButtonLabel, profileInformationLabel, passwordLabel, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, messages, uiSizes, fileTypes, }: MySettingsLayoutProps): import("react").JSX.Element;
70
78
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/my_settings/index.tsx"],"names":[],"mappings":"AAcA,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,uCAAuC,CAAC;AAQ/C,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,qBAAqB,EAAE,0BAA0B,CAAC;IAClD,cAAc,EAAE;QACd,kBAAkB,EAAE,OAAO,CAAC;QAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,4BAA4B,EAAE,UAAU,GAAG,SAAS,CAAC;QACrD,4BAA4B,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;QACtD,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,UAAU,EAAE;QACV,eA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C,CAAC;CACH,CAAC;AAGF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,SAAS,EACT,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,UAAU,EACV,mBAAkE,EAClE,gBAAgC,EAChC,SAA8B,EAC9B,qBAA6B,EAC7B,OAA4B,EAC5B,UAAoE,EACpE,iBAAmC,EACnC,0BAAqE,EACrE,sBAA2C,EAC3C,sBAAiC,EACjC,uBAA+C,EAC/C,aAA0B,EAC1B,oBAAyC,EACzC,gBAAiC,EACjC,oBAAyC,EACzC,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE,qBAAqB,+BA2OvB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/my_settings/index.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAGnG,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,uCAAuC,CAAC;AAQ/C,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,qBAAqB,EAAE,0BAA0B,CAAC;IAClD,cAAc,EAAE;QACd,kBAAkB,EAAE,OAAO,CAAC;QAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,4BAA4B,EAAE,UAAU,GAAG,SAAS,CAAC;QACrD,4BAA4B,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;QACtD,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,UAAU,EAAE;QACV,eAAe,EAAE,OAAO,CAA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ACnC,wBAAwB,EAAE,MAAM,EAAE,CAAC;KACpC,CAAC;CACH,CAAC;AAGF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,SAAS,EACT,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,UAAU,EACV,mBAAkE,EAClE,gBAAgC,EAChC,SAA8B,EAC9B,gBAAgB,EAChB,qBAA6B,EAC7B,OAA4B,EAC5B,UAAoE,EACpE,iBAAmC,EACnC,0BAAqE,EACrE,sBAA2C,EAC3C,sBAAiC,EACjC,uBAA+C,EAC/C,aAA0B,EAC1B,oBAAyC,EACzC,gBAAiC,EACjC,oBAAyC,EACzC,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE,qBAAqB,+BAmPvB"}
@@ -10,6 +10,7 @@ import { ProfilePictureDialog } from "./components/profile_picture_dialog.js";
10
10
  import { ConnectedAccountsSection } from "./components/connected_accounts_section.js";
11
11
  import { SetPasswordSection } from "./components/set_password_section.js";
12
12
  import { DangerZoneSection } from "./components/danger_zone_section.js";
13
+ import { LanguagePickerSection } from "./components/language_picker_section.js";
13
14
  import { UnauthorizedGuard } from "../shared/components/unauthorized_guard.js";
14
15
  import { use_my_settings } from "./hooks/use_my_settings.js";
15
16
  import { resolveMySettingsLabels, resolveMySettingsButtonPalette, } from "./config/my_settings_field_config.js";
@@ -25,14 +26,14 @@ import { cn } from "../../../lib/utils.js";
25
26
  * @param props - Component props including labels, button colors, password requirements, etc.
26
27
  * @returns My settings layout component
27
28
  */
28
- export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage = "You must be logged in to access this page.", loginButtonLabel = "Go to login", loginPath = "/hazo_auth/login", enableAccountDeletion = false, heading = "Account Settings", subHeading = "Manage your profile, password, and email preferences.", profilePhotoLabel = "Profile Photo", profilePhotoRecommendation = "Recommended size: 200x200px. JPG, PNG.", uploadPhotoButtonLabel = "Upload New Photo", removePhotoButtonLabel = "Remove", profileInformationLabel = "Profile Information", passwordLabel = "Password", currentPasswordLabel = "Current Password", newPasswordLabel = "New Password", confirmPasswordLabel = "Confirm Password", messages, uiSizes, fileTypes, }) {
29
+ export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage = "You must be logged in to access this page.", loginButtonLabel = "Go to login", loginPath = "/hazo_auth/login", availableLocales, enableAccountDeletion = false, heading = "Account Settings", subHeading = "Manage your profile, password, and email preferences.", profilePhotoLabel = "Profile Photo", profilePhotoRecommendation = "Recommended size: 200x200px. JPG, PNG.", uploadPhotoButtonLabel = "Upload New Photo", removePhotoButtonLabel = "Remove", profileInformationLabel = "Profile Information", passwordLabel = "Password", currentPasswordLabel = "Current Password", newPasswordLabel = "New Password", confirmPasswordLabel = "Confirm Password", messages, uiSizes, fileTypes, }) {
29
30
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
30
31
  const resolvedLabels = resolveMySettingsLabels(labels);
31
32
  const resolvedButtonPalette = resolveMySettingsButtonPalette(button_colors);
32
33
  const settings = use_my_settings({
33
34
  passwordRequirements: password_requirements,
34
35
  });
35
- return (_jsx(UnauthorizedGuard, { message: unauthorizedMessage, loginButtonLabel: loginButtonLabel, loginPath: loginPath, children: _jsxs("div", { className: cn("cls_my_settings_layout flex flex-col gap-6 p-6 w-full", className), children: [_jsxs("div", { className: "cls_my_settings_layout_header flex flex-col gap-2", children: [_jsx("h1", { className: "cls_my_settings_layout_heading text-3xl font-bold text-[var(--hazo-text-primary)]", children: heading }), _jsx("p", { className: "cls_my_settings_layout_subheading text-[var(--hazo-text-muted)]", children: subHeading })] }), _jsxs("div", { className: "cls_my_settings_layout_profile_photo_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: profilePhotoLabel }), _jsx("div", { className: "cls_my_settings_layout_profile_photo_content flex flex-col items-center", children: _jsxs("div", { className: "cls_my_settings_layout_profile_photo_display relative", children: [_jsx(ProfilePictureDisplay, { profilePictureUrl: settings.profilePictureUrl, name: settings.name, email: settings.email, onEdit: settings.handleProfilePictureEdit }), _jsxs("div", { className: "cls_my_settings_layout_profile_photo_actions absolute left-0 right-0 flex items-center justify-between px-2", style: { bottom: '-20px' }, children: [_jsx(Button, { type: "button", onClick: settings.handleProfilePictureEdit, disabled: settings.loading, variant: "ghost", size: "icon", className: "cls_my_settings_layout_upload_photo_button", "aria-label": uploadPhotoButtonLabel, children: _jsx(Pencil, { className: "h-4 w-4", "aria-hidden": "true" }) }), _jsx(Button, { type: "button", onClick: settings.handleProfilePictureRemove, disabled: settings.loading || !settings.profilePictureUrl, variant: "ghost", size: "icon", className: "cls_my_settings_layout_remove_photo_button text-red-600 hover:text-red-700 hover:bg-red-50", "aria-label": removePhotoButtonLabel, children: _jsx(Trash2, { className: "h-4 w-4", "aria-hidden": "true" }) })] })] }) })] }), _jsxs("div", { className: "cls_my_settings_layout_profile_information_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: profileInformationLabel }), _jsxs("div", { className: "cls_my_settings_layout_profile_information_fields grid grid-cols-1 md:grid-cols-2 gap-6", children: [userFields.show_name_field && (_jsx(EditableField, { label: "Full Name", value: settings.name, type: "text", placeholder: "Enter your full name", onSave: settings.handleNameSave, validation: validateName, disabled: settings.loading, ariaLabel: "Full name input field" })), userFields.show_email_field && (_jsx(EditableField, { label: "Email Address", value: settings.email, type: "email", placeholder: "Enter your email address", onSave: settings.handleEmailSave, validation: validateEmail, disabled: settings.loading, ariaLabel: "Email address input field" }))] })] }), userFields.show_password_field && settings.hasPassword && (_jsxs("div", { className: "cls_my_settings_layout_password_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: passwordLabel }), _jsxs("div", { className: "cls_my_settings_layout_password_fields flex flex-col gap-6", children: [_jsx(FormFieldWrapper, { fieldId: "current-password", label: currentPasswordLabel, input: _jsx(PasswordField, { inputId: "current-password", ariaLabel: currentPasswordLabel, value: ((_a = settings.passwordFields) === null || _a === void 0 ? void 0 : _a.currentPassword) || "", placeholder: "Enter your current password", autoComplete: "current-password", isVisible: ((_b = settings.passwordFields) === null || _b === void 0 ? void 0 : _b.currentPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("currentPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("currentPassword"), errorMessage: (_d = (_c = settings.passwordFields) === null || _c === void 0 ? void 0 : _c.errors) === null || _d === void 0 ? void 0 : _d.currentPassword }) }), _jsxs("div", { className: "cls_my_settings_layout_password_fields_row grid grid-cols-1 md:grid-cols-2 gap-6", children: [_jsx(FormFieldWrapper, { fieldId: "new-password", label: newPasswordLabel, input: _jsx(PasswordField, { inputId: "new-password", ariaLabel: newPasswordLabel, value: ((_e = settings.passwordFields) === null || _e === void 0 ? void 0 : _e.newPassword) || "", placeholder: "Enter your new password", autoComplete: "new-password", isVisible: ((_f = settings.passwordFields) === null || _f === void 0 ? void 0 : _f.newPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("newPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("newPassword"), errorMessage: (_h = (_g = settings.passwordFields) === null || _g === void 0 ? void 0 : _g.errors) === null || _h === void 0 ? void 0 : _h.newPassword }) }), _jsx(FormFieldWrapper, { fieldId: "confirm-password", label: confirmPasswordLabel, input: _jsx(PasswordField, { inputId: "confirm-password", ariaLabel: confirmPasswordLabel, value: ((_j = settings.passwordFields) === null || _j === void 0 ? void 0 : _j.confirmPassword) || "", placeholder: "Confirm your new password", autoComplete: "new-password", isVisible: ((_k = settings.passwordFields) === null || _k === void 0 ? void 0 : _k.confirmPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("confirmPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("confirmPassword"), errorMessage: (_m = (_l = settings.passwordFields) === null || _l === void 0 ? void 0 : _l.errors) === null || _m === void 0 ? void 0 : _m.confirmPassword }) })] })] }), _jsx("div", { className: "cls_my_settings_layout_password_actions flex justify-end mt-4", children: _jsx(Button, { type: "button", onClick: settings.handlePasswordSave, disabled: settings.loading || settings.isPasswordSaveDisabled, className: "cls_my_settings_layout_save_password_button", style: {
36
+ return (_jsx(UnauthorizedGuard, { message: unauthorizedMessage, loginButtonLabel: loginButtonLabel, loginPath: loginPath, children: _jsxs("div", { className: cn("cls_my_settings_layout flex flex-col gap-6 p-6 w-full", className), children: [_jsxs("div", { className: "cls_my_settings_layout_header flex flex-col gap-2", children: [_jsx("h1", { className: "cls_my_settings_layout_heading text-3xl font-bold text-[var(--hazo-text-primary)]", children: heading }), _jsx("p", { className: "cls_my_settings_layout_subheading text-[var(--hazo-text-muted)]", children: subHeading })] }), _jsxs("div", { className: "cls_my_settings_layout_profile_photo_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: profilePhotoLabel }), _jsx("div", { className: "cls_my_settings_layout_profile_photo_content flex flex-col items-center", children: _jsxs("div", { className: "cls_my_settings_layout_profile_photo_display relative", children: [_jsx(ProfilePictureDisplay, { profilePictureUrl: settings.profilePictureUrl, name: settings.name, email: settings.email, onEdit: settings.handleProfilePictureEdit }), _jsxs("div", { className: "cls_my_settings_layout_profile_photo_actions absolute left-0 right-0 flex items-center justify-between px-2", style: { bottom: '-20px' }, children: [_jsx(Button, { type: "button", onClick: settings.handleProfilePictureEdit, disabled: settings.loading, variant: "ghost", size: "icon", className: "cls_my_settings_layout_upload_photo_button", "aria-label": uploadPhotoButtonLabel, children: _jsx(Pencil, { className: "h-4 w-4", "aria-hidden": "true" }) }), _jsx(Button, { type: "button", onClick: settings.handleProfilePictureRemove, disabled: settings.loading || !settings.profilePictureUrl, variant: "ghost", size: "icon", className: "cls_my_settings_layout_remove_photo_button text-red-600 hover:text-red-700 hover:bg-red-50", "aria-label": removePhotoButtonLabel, children: _jsx(Trash2, { className: "h-4 w-4", "aria-hidden": "true" }) })] })] }) })] }), _jsxs("div", { className: "cls_my_settings_layout_profile_information_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: profileInformationLabel }), _jsxs("div", { className: "cls_my_settings_layout_profile_information_fields grid grid-cols-1 md:grid-cols-2 gap-6", children: [userFields.show_name_field && (_jsx(EditableField, { label: "Full Name", value: settings.name, type: "text", placeholder: "Enter your full name", onSave: settings.handleNameSave, validation: validateName, disabled: settings.loading, ariaLabel: "Full name input field" })), userFields.show_email_field && (_jsx(EditableField, { label: "Email Address", value: settings.email, type: "email", placeholder: "Enter your email address", onSave: settings.handleEmailSave, validation: validateEmail, disabled: settings.loading, ariaLabel: "Email address input field" })), _jsx(LanguagePickerSection, { availableLocales: availableLocales, currentLocale: settings.preferredLocale, onLocaleChange: settings.handlePreferredLocaleSave, disabled: settings.loading })] })] }), userFields.show_password_field && settings.hasPassword && (_jsxs("div", { className: "cls_my_settings_layout_password_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: passwordLabel }), _jsxs("div", { className: "cls_my_settings_layout_password_fields flex flex-col gap-6", children: [_jsx(FormFieldWrapper, { fieldId: "current-password", label: currentPasswordLabel, input: _jsx(PasswordField, { inputId: "current-password", ariaLabel: currentPasswordLabel, value: ((_a = settings.passwordFields) === null || _a === void 0 ? void 0 : _a.currentPassword) || "", placeholder: "Enter your current password", autoComplete: "current-password", isVisible: ((_b = settings.passwordFields) === null || _b === void 0 ? void 0 : _b.currentPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("currentPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("currentPassword"), errorMessage: (_d = (_c = settings.passwordFields) === null || _c === void 0 ? void 0 : _c.errors) === null || _d === void 0 ? void 0 : _d.currentPassword }) }), _jsxs("div", { className: "cls_my_settings_layout_password_fields_row grid grid-cols-1 md:grid-cols-2 gap-6", children: [_jsx(FormFieldWrapper, { fieldId: "new-password", label: newPasswordLabel, input: _jsx(PasswordField, { inputId: "new-password", ariaLabel: newPasswordLabel, value: ((_e = settings.passwordFields) === null || _e === void 0 ? void 0 : _e.newPassword) || "", placeholder: "Enter your new password", autoComplete: "new-password", isVisible: ((_f = settings.passwordFields) === null || _f === void 0 ? void 0 : _f.newPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("newPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("newPassword"), errorMessage: (_h = (_g = settings.passwordFields) === null || _g === void 0 ? void 0 : _g.errors) === null || _h === void 0 ? void 0 : _h.newPassword }) }), _jsx(FormFieldWrapper, { fieldId: "confirm-password", label: confirmPasswordLabel, input: _jsx(PasswordField, { inputId: "confirm-password", ariaLabel: confirmPasswordLabel, value: ((_j = settings.passwordFields) === null || _j === void 0 ? void 0 : _j.confirmPassword) || "", placeholder: "Confirm your new password", autoComplete: "new-password", isVisible: ((_k = settings.passwordFields) === null || _k === void 0 ? void 0 : _k.confirmPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("confirmPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("confirmPassword"), errorMessage: (_m = (_l = settings.passwordFields) === null || _l === void 0 ? void 0 : _l.errors) === null || _m === void 0 ? void 0 : _m.confirmPassword }) })] })] }), _jsx("div", { className: "cls_my_settings_layout_password_actions flex justify-end mt-4", children: _jsx(Button, { type: "button", onClick: settings.handlePasswordSave, disabled: settings.loading || settings.isPasswordSaveDisabled, className: "cls_my_settings_layout_save_password_button", style: {
36
37
  backgroundColor: resolvedButtonPalette.submitBackground,
37
38
  color: resolvedButtonPalette.submitText,
38
39
  }, "aria-label": "Save password", children: "Save Password" }) })] })), !settings.hasPassword && settings.googleConnected && (_jsx(SetPasswordSection, { passwordRequirements: password_requirements, onPasswordSet: settings.refreshUserData, parentLoading: settings.loading })), _jsx(ConnectedAccountsSection, { googleConnected: settings.googleConnected || false, email: settings.email, loading: settings.loading }), _jsx(DangerZoneSection, { enabled: enableAccountDeletion, email: settings.email }), _jsx(ProfilePictureDialog, { open: settings.profilePictureDialogOpen, onOpenChange: (open) => {
@@ -10,6 +10,7 @@ export type AuthStatusData = {
10
10
  avatar_url?: string;
11
11
  image?: string;
12
12
  profile_source?: "upload" | "library" | "gravatar" | "custom";
13
+ preferred_locale?: string | null;
13
14
  permissions?: string[];
14
15
  permission_ok?: boolean;
15
16
  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;IAC9D,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,CA2E5C"}
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;IACjC,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,CA4E5C"}
@@ -23,7 +23,7 @@ export function use_auth_status() {
23
23
  loading: true,
24
24
  });
25
25
  const checkAuth = useCallback(async () => {
26
- var _a;
26
+ var _a, _b;
27
27
  setAuthStatus((prev) => (Object.assign(Object.assign({}, prev), { loading: true })));
28
28
  try {
29
29
  const response = await fetch(`${apiBasePath}/me`, {
@@ -45,8 +45,9 @@ export function use_auth_status() {
45
45
  avatar_url: data.avatar_url,
46
46
  image: data.image,
47
47
  profile_source: data.profile_source,
48
+ preferred_locale: (_a = data.preferred_locale) !== null && _a !== void 0 ? _a : null,
48
49
  permissions: data.permissions || [],
49
- permission_ok: (_a = data.permission_ok) !== null && _a !== void 0 ? _a : true,
50
+ permission_ok: (_b = data.permission_ok) !== null && _b !== void 0 ? _b : true,
50
51
  missing_permissions: data.missing_permissions,
51
52
  // OAuth-related fields
52
53
  auth_providers: data.auth_providers,
@@ -11,6 +11,7 @@ export type HazoAuthUser = {
11
11
  managed_by_user_id?: string | null;
12
12
  app_user_data: Record<string, unknown> | null;
13
13
  legal_acceptance: LegalAcceptanceMap | null;
14
+ preferred_locale: string | null;
14
15
  };
15
16
  /**
16
17
  * 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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C,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;AA4SD;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,cAAc,CAAC,CA+NzB"}
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;AA6SD;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,cAAc,CAAC,CA+NzB"}
@@ -153,6 +153,7 @@ async function fetch_user_data_from_db(user_id) {
153
153
  managed_by_user_id: user_db.managed_by_user_id || null,
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
+ preferred_locale: user_db.preferred_locale || null,
156
157
  };
157
158
  // v5.x: Fetch user's roles from hazo_user_scopes (scope-based role assignments)
158
159
  // Each scope assignment has a role_id (string UUID)
@@ -1 +1 @@
1
- {"version":3,"file":"oauth_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/oauth_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AASvD,MAAM,MAAM,eAAe,GAAG;IAC5B,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,6CAA6C;IAC7C,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,oFAAoF;IACpF,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uDAAuD;IACvD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,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
26
  const users_by_google_id = await users_service.findBy({ google_id });
27
27
  if (Array.isArray(users_by_google_id) && users_by_google_id.length > 0) {
28
28
  const user = users_by_google_id[0];
29
- // Update last_logon timestamp
30
- await users_service.updateById(user.id, {
31
- last_logon: now,
32
- changed_at: now,
33
- });
29
+ // Update last_logon timestamp. Google is the source of truth for this
30
+ // user's avatar on this path (they just authenticated via Google, and
31
+ // google_id already matches), so refresh profile_picture_url whenever
32
+ // Google provides a truthy value — regardless of what's already stored.
33
+ // This handles CDN URL rotation, unlike Step 2/3's first-time-population
34
+ // guard (`!user.profile_picture_url && profile_picture_url`).
35
+ await users_service.updateById(user.id, Object.assign({ last_logon: now, changed_at: now }, (profile_picture_url ? { profile_picture_url, profile_source: "custom" } : {})));
34
36
  logger.info("oauth_service_google_login_existing_google_user", {
35
37
  filename: "oauth_service.ts",
36
38
  line_number: get_line_number(),
@@ -182,7 +184,12 @@ export async function handle_facebook_oauth_login(adapter, data) {
182
184
  const users_by_fb_id = await users_service.findBy({ facebook_id });
183
185
  if (Array.isArray(users_by_fb_id) && users_by_fb_id.length > 0) {
184
186
  const user = users_by_fb_id[0];
185
- await users_service.updateById(user.id, { last_logon: now, changed_at: now });
187
+ // Facebook is the source of truth for this user's avatar on this path
188
+ // (they just authenticated via Facebook, and facebook_id already
189
+ // matches), so refresh profile_picture_url whenever Facebook provides a
190
+ // truthy value — regardless of what's already stored. This handles CDN
191
+ // URL rotation, unlike Step 2/3's first-time-population guard.
192
+ await users_service.updateById(user.id, Object.assign({ last_logon: now, changed_at: now }, (profile_picture_url ? { profile_picture_url, profile_source: "custom" } : {})));
186
193
  logger.info("oauth_service_facebook_login_existing_fb_user", {
187
194
  filename: "oauth_service.ts",
188
195
  user_id: user.id,
@@ -5,6 +5,7 @@ export type UserUpdateData = {
5
5
  email?: string;
6
6
  profile_picture_url?: string;
7
7
  profile_source?: ProfilePictureSourceUI;
8
+ preferred_locale?: string | null;
8
9
  };
9
10
  export type UserUpdateResult = {
10
11
  success: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"user_update_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/user_update_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAuB,KAAK,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAMnG,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,cAAc,CAAC,EAAE,sBAAsB,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,gBAAgB,CAAC,CAuG3B"}
1
+ {"version":3,"file":"user_update_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/user_update_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAuB,KAAK,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAMnG,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,cAAc,CAAC,EAAE,sBAAsB,CAAC;IAIxC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,gBAAgB,CAAC,CA4G3B"}
@@ -71,6 +71,10 @@ export async function update_user_profile(adapter, user_id, data) {
71
71
  // Map UI source value to database enum value
72
72
  update_data.profile_source = map_ui_source_to_db(data.profile_source);
73
73
  }
74
+ if (data.preferred_locale !== undefined) {
75
+ // null explicitly clears the preference (falls back to detection elsewhere)
76
+ update_data.preferred_locale = data.preferred_locale;
77
+ }
74
78
  // If email changed, set email_verified to false
75
79
  if (email_changed) {
76
80
  update_data.email_verified = false;
@@ -11,11 +11,11 @@ export declare function GET(request: NextRequest): Promise<NextResponse<{
11
11
  has_more: boolean;
12
12
  total_pages: number;
13
13
  };
14
- source: "node_modules" | "project";
14
+ source: "project" | "node_modules";
15
15
  }> | NextResponse<{
16
16
  success: boolean;
17
17
  categories: string[];
18
- source: "node_modules" | "project" | null;
18
+ source: "project" | "node_modules" | null;
19
19
  }> | NextResponse<{
20
20
  error: string;
21
21
  }>>;
@@ -1 +1 @@
1
- {"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../src/server/routes/me.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoBxD;;;;;GAKG;AACH,wBAAsB,GAAG,CAAC,OAAO,EAAE,WAAW;;IAiH7C"}
1
+ {"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../src/server/routes/me.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoBxD;;;;;GAKG;AACH,wBAAsB,GAAG,CAAC,OAAO,EAAE,WAAW;;IAmH7C"}
@@ -24,7 +24,7 @@ function strip_sentinel_email(email) {
24
24
  * Always returns the same format to prevent downstream variations.
25
25
  */
26
26
  export async function GET(request) {
27
- var _a;
27
+ var _a, _b;
28
28
  const logger = create_app_logger();
29
29
  try {
30
30
  // Use hazo_get_auth to get user with permissions
@@ -97,6 +97,8 @@ export async function GET(request) {
97
97
  app_user_data: auth_result.user.app_user_data,
98
98
  // Legal documents the user has accepted (map of key -> { hash, accepted_at })
99
99
  legal_acceptance: (_a = auth_result.user.legal_acceptance) !== null && _a !== void 0 ? _a : null,
100
+ // User's explicit locale preference (BCP 47 tag), or null if unset
101
+ preferred_locale: (_b = auth_result.user.preferred_locale) !== null && _b !== void 0 ? _b : null,
100
102
  // Permissions and user object (always included)
101
103
  user: auth_result.user,
102
104
  permissions: auth_result.permissions,
@@ -1 +1 @@
1
- {"version":3,"file":"update_user.d.ts","sourceRoot":"","sources":["../../../src/server/routes/update_user.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AASxD,wBAAsB,KAAK,CAAC,OAAO,EAAE,WAAW;;;;;;IAoH/C"}
1
+ {"version":3,"file":"update_user.d.ts","sourceRoot":"","sources":["../../../src/server/routes/update_user.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA0BxD,wBAAsB,KAAK,CAAC,OAAO,EAAE,WAAW;;;;;;IAyI/C"}
@@ -7,6 +7,22 @@ import { update_user_profile } from "../../lib/services/user_update_service.js";
7
7
  import { get_filename, get_line_number } from "../../lib/utils/api_route_helpers.js";
8
8
  import { require_auth } from "../../lib/auth/auth_utils.server.js";
9
9
  import { get_cookie_name, get_cookie_options, BASE_COOKIE_NAMES } from "../../lib/cookies_config.server.js";
10
+ // section: constants
11
+ // BCP 47 language tag, optionally followed by a region/script subtag
12
+ // (e.g. "en", "en-US", "pt-BR", "zh-Hans"). Deliberately NOT an allowlist — any
13
+ // syntactically valid tag is accepted, since the set of supported locales is owned
14
+ // by the consuming app, not hazo_auth.
15
+ const BCP47_LOCALE_REGEX = /^[a-z]{2,3}(-[A-Za-z]{2,4})?$/;
16
+ /**
17
+ * Validates a preferred_locale value from a PATCH body.
18
+ * @param value - Raw value from the request body
19
+ * @returns True if value is `null` (explicit clear) or a syntactically valid BCP 47 tag
20
+ */
21
+ function is_valid_preferred_locale(value) {
22
+ if (value === null)
23
+ return true;
24
+ return typeof value === "string" && value.length <= 10 && BCP47_LOCALE_REGEX.test(value);
25
+ }
10
26
  // section: api_handler
11
27
  export async function PATCH(request) {
12
28
  const logger = create_app_logger();
@@ -29,15 +45,28 @@ export async function PATCH(request) {
29
45
  throw error;
30
46
  }
31
47
  const body = await request.json();
32
- const { name, email, profile_picture_url, profile_source } = body;
48
+ const { name, email, profile_picture_url, profile_source, preferred_locale } = body;
33
49
  // Validate input (at least one field must be provided)
34
- if (name === undefined && email === undefined && profile_picture_url === undefined) {
50
+ if (name === undefined &&
51
+ email === undefined &&
52
+ profile_picture_url === undefined &&
53
+ preferred_locale === undefined) {
35
54
  logger.warn("user_update_validation_failed", {
36
55
  filename: get_filename(),
37
56
  line_number: get_line_number(),
38
57
  error: "No fields to update",
39
58
  });
40
- return NextResponse.json({ error: "At least one field (name, email, or profile_picture_url) must be provided" }, { status: 400 });
59
+ return NextResponse.json({ error: "At least one field (name, email, profile_picture_url, or preferred_locale) must be provided" }, { status: 400 });
60
+ }
61
+ // Validate preferred_locale (BCP 47 tag, or null to clear the preference)
62
+ if (preferred_locale !== undefined && !is_valid_preferred_locale(preferred_locale)) {
63
+ logger.warn("user_update_validation_failed", {
64
+ filename: get_filename(),
65
+ line_number: get_line_number(),
66
+ error: "Invalid preferred_locale",
67
+ preferred_locale,
68
+ });
69
+ return NextResponse.json({ error: "Invalid preferred_locale. Expected a BCP 47 locale tag (e.g. \"en\", \"pt-BR\") or null." }, { status: 400 });
41
70
  }
42
71
  // Get singleton hazo_connect instance
43
72
  const hazoConnect = get_hazo_connect_instance();
@@ -47,6 +76,7 @@ export async function PATCH(request) {
47
76
  email,
48
77
  profile_picture_url,
49
78
  profile_source,
79
+ preferred_locale,
50
80
  });
51
81
  if (!result.success) {
52
82
  logger.warn("user_update_failed", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hazo_auth",
3
- "version": "10.15.0",
3
+ "version": "10.17.0",
4
4
  "description": "Zero-config authentication UI components for Next.js with RBAC, OAuth, scope-based multi-tenancy, and invitations",
5
5
  "keywords": [
6
6
  "authentication",
@@ -271,14 +271,14 @@
271
271
  "multer": "^2.0.2"
272
272
  },
273
273
  "peerDependencies": {
274
- "hazo_config": "^2.4.1",
275
- "hazo_connect": "^4.0.0",
276
- "hazo_core": "^1.3.0",
277
- "hazo_logs": "^2.1.1",
278
- "hazo_notify": "^6.1.4",
279
- "hazo_secure": "^1.7.0",
280
- "hazo_theme": "^1.0.1",
281
- "hazo_ui": "^6.3.1",
274
+ "hazo_config": "^2.4.3",
275
+ "hazo_connect": "^4.1.0",
276
+ "hazo_core": "^2.2.0",
277
+ "hazo_logs": "^2.2.1",
278
+ "hazo_notify": "^6.2.0",
279
+ "hazo_secure": "^1.7.4",
280
+ "hazo_theme": "^1.3.1",
281
+ "hazo_ui": "^6.11.0",
282
282
  "next": "^14.0.0 || ^15.0.0 || ^16.0.0",
283
283
  "next-auth": "^4.24.0",
284
284
  "react": "^18.0.0 || ^19.0.0",
@@ -353,14 +353,14 @@
353
353
  "eslint": "^9.39.1",
354
354
  "eslint-config-next": "^16.0.4",
355
355
  "eslint-plugin-storybook": "^10.0.6",
356
- "hazo_api": "^2.6.0",
357
- "hazo_config": "^2.4.2",
358
- "hazo_connect": "^4.0.0",
359
- "hazo_core": "^1.3.1",
360
- "hazo_logs": "^2.2.0",
361
- "hazo_notify": "^6.1.5",
362
- "hazo_theme": "^1.3.0",
363
- "hazo_ui": "^6.8.0",
356
+ "hazo_api": "^2.6.1",
357
+ "hazo_config": "^2.4.3",
358
+ "hazo_connect": "^4.1.0",
359
+ "hazo_core": "^2.2.0",
360
+ "hazo_logs": "^2.2.1",
361
+ "hazo_notify": "^6.2.0",
362
+ "hazo_theme": "^1.3.1",
363
+ "hazo_ui": "^6.11.0",
364
364
  "input-otp": "^1.4.0",
365
365
  "jest": "^30.2.0",
366
366
  "jest-environment-jsdom": "^30.0.0",