hazo_auth 10.19.0 → 10.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/SETUP_CHECKLIST.md +27 -0
- package/cli-src/lib/already_logged_in_config.server.ts +11 -7
- package/cli-src/lib/auth_hooks.ts +52 -0
- package/cli-src/lib/config/config_loader.server.ts +34 -0
- package/cli-src/lib/email_verification_config.server.ts +2 -2
- package/cli-src/lib/forgot_password_config.server.ts +2 -2
- package/cli-src/lib/login_config.server.ts +25 -19
- package/cli-src/lib/my_settings_config.server.ts +22 -15
- package/cli-src/lib/navbar_config.server.ts +12 -8
- package/cli-src/lib/oauth_config.server.ts +14 -22
- package/cli-src/lib/otp_config.server.ts +11 -4
- package/cli-src/lib/profile_pic_menu_config.server.ts +16 -5
- package/cli-src/lib/register_config.server.ts +21 -16
- package/cli-src/lib/reset_password_config.server.ts +11 -17
- package/cli-src/lib/services/oauth_service.ts +16 -0
- package/cli-src/lib/services/otp_service.ts +7 -0
- package/cli-src/lib/services/registration_service.ts +8 -0
- package/cli-src/lib/ui_shell_config.server.ts +11 -13
- package/dist/components/layouts/create_firm/index.d.ts.map +1 -1
- package/dist/components/layouts/create_firm/index.js +4 -3
- package/dist/components/layouts/dev_lock/index.d.ts.map +1 -1
- package/dist/components/layouts/dev_lock/index.js +4 -2
- package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts +5 -4
- package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/config/email_verification_field_config.js +20 -20
- package/dist/components/layouts/email_verification/hooks/use_email_verification.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/hooks/use_email_verification.js +5 -7
- package/dist/components/layouts/email_verification/index.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/index.js +13 -12
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts +3 -2
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.js +16 -16
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.js +5 -7
- package/dist/components/layouts/forgot_password/index.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/index.js +15 -9
- 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/legal/legal_doc_checkbox_list.d.ts.map +1 -1
- package/dist/components/layouts/legal/legal_doc_checkbox_list.js +3 -1
- package/dist/components/layouts/legal/legal_doc_combined_view.d.ts.map +1 -1
- package/dist/components/layouts/legal/legal_doc_combined_view.js +3 -1
- package/dist/components/layouts/login/config/login_field_config.d.ts +3 -2
- package/dist/components/layouts/login/config/login_field_config.d.ts.map +1 -1
- package/dist/components/layouts/login/config/login_field_config.js +24 -24
- package/dist/components/layouts/login/hooks/use_login_form.d.ts.map +1 -1
- package/dist/components/layouts/login/hooks/use_login_form.js +5 -7
- package/dist/components/layouts/login/index.d.ts +4 -4
- package/dist/components/layouts/login/index.d.ts.map +1 -1
- package/dist/components/layouts/login/index.js +30 -22
- package/dist/components/layouts/my_settings/components/connected_accounts_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/connected_accounts_section.js +5 -5
- package/dist/components/layouts/my_settings/components/danger_zone_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/danger_zone_section.js +12 -6
- package/dist/components/layouts/my_settings/components/editable_field.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/editable_field.js +4 -2
- package/dist/components/layouts/my_settings/components/language_picker_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/language_picker_section.js +7 -3
- package/dist/components/layouts/my_settings/components/password_change_dialog.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/password_change_dialog.js +28 -21
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.js +12 -9
- package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.js +3 -1
- package/dist/components/layouts/my_settings/components/profile_picture_library_tab.js +14 -11
- package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.js +26 -15
- package/dist/components/layouts/my_settings/components/set_password_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/set_password_section.js +9 -6
- package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts +2 -1
- package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/config/my_settings_field_config.js +4 -7
- package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/index.js +35 -27
- package/dist/components/layouts/otp/index.d.ts.map +1 -1
- package/dist/components/layouts/otp/index.js +8 -6
- package/dist/components/layouts/register/config/register_field_config.d.ts +3 -2
- package/dist/components/layouts/register/config/register_field_config.d.ts.map +1 -1
- package/dist/components/layouts/register/config/register_field_config.js +40 -40
- package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -1
- package/dist/components/layouts/register/hooks/use_register_form.js +7 -9
- package/dist/components/layouts/register/index.d.ts +4 -4
- package/dist/components/layouts/register/index.d.ts.map +1 -1
- package/dist/components/layouts/register/index.js +22 -19
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts +4 -3
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/config/reset_password_field_config.js +7 -10
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.js +4 -6
- package/dist/components/layouts/reset_password/index.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/index.js +12 -10
- 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 +6 -5
- package/dist/components/layouts/shared/components/auth_navbar.d.ts +1 -1
- package/dist/components/layouts/shared/components/auth_navbar.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/auth_navbar.js +7 -2
- package/dist/components/layouts/shared/components/facebook_sign_in_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/facebook_sign_in_button.js +5 -5
- package/dist/components/layouts/shared/components/floating_home_link.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/floating_home_link.js +6 -3
- package/dist/components/layouts/shared/components/form_action_buttons.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/form_action_buttons.js +9 -7
- package/dist/components/layouts/shared/components/google_sign_in_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/google_sign_in_button.js +5 -5
- package/dist/components/layouts/shared/components/logout_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/logout_button.js +2 -4
- package/dist/components/layouts/shared/components/oauth_divider.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/oauth_divider.js +8 -6
- package/dist/components/layouts/shared/components/password_field.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/password_field.js +2 -3
- package/dist/components/layouts/shared/components/profile_pic_menu.d.ts +4 -0
- package/dist/components/layouts/shared/components/profile_pic_menu.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/profile_pic_menu.js +26 -18
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.d.ts +1 -0
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.js +1 -1
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.js +3 -1
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.js +6 -2
- package/dist/components/layouts/shared/components/unauthorized_guard.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/unauthorized_guard.js +6 -5
- package/dist/components/layouts/shared/config/layout_customization.d.ts +2 -1
- package/dist/components/layouts/shared/config/layout_customization.d.ts.map +1 -1
- package/dist/components/layouts/shared/config/layout_customization.js +18 -7
- package/dist/components/layouts/shared/utils/validation.d.ts +5 -2
- package/dist/components/layouts/shared/utils/validation.d.ts.map +1 -1
- package/dist/components/layouts/shared/utils/validation.js +4 -8
- package/dist/components/layouts/user_management/components/roles_matrix.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/roles_matrix.js +2 -4
- package/dist/components/layouts/user_management/components/scope_hierarchy_tab.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/scope_hierarchy_tab.js +6 -8
- package/dist/components/layouts/user_management/components/user_scopes_tab.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/user_scopes_tab.js +2 -4
- package/dist/components/layouts/user_management/index.d.ts.map +1 -1
- package/dist/components/layouts/user_management/index.js +2 -4
- package/dist/components/otp/OTPRequestForm.d.ts.map +1 -1
- package/dist/components/otp/OTPRequestForm.js +7 -5
- package/dist/components/otp/OTPVerifyForm.d.ts.map +1 -1
- package/dist/components/otp/OTPVerifyForm.js +7 -5
- package/dist/components/permission_denied_dialog.client.d.ts.map +1 -1
- package/dist/components/permission_denied_dialog.client.js +6 -6
- package/dist/components/ui/sheet.d.ts +1 -1
- package/dist/components/ui/sidebar.js +5 -5
- package/dist/contexts/hazo_auth_config.d.ts +13 -0
- package/dist/contexts/hazo_auth_config.d.ts.map +1 -1
- package/dist/contexts/hazo_auth_config.js +4 -1
- package/dist/contexts/hazo_auth_provider.d.ts +22 -2
- package/dist/contexts/hazo_auth_provider.d.ts.map +1 -1
- package/dist/contexts/hazo_auth_provider.js +18 -2
- package/dist/lib/already_logged_in_config.server.d.ts +4 -2
- package/dist/lib/already_logged_in_config.server.d.ts.map +1 -1
- package/dist/lib/already_logged_in_config.server.js +7 -5
- package/dist/lib/auth_hooks.d.ts +20 -0
- package/dist/lib/auth_hooks.d.ts.map +1 -0
- package/dist/lib/auth_hooks.js +32 -0
- package/dist/lib/config/config_loader.server.d.ts +23 -0
- package/dist/lib/config/config_loader.server.d.ts.map +1 -1
- package/dist/lib/config/config_loader.server.js +29 -0
- package/dist/lib/email_verification_config.server.d.ts +2 -2
- package/dist/lib/email_verification_config.server.d.ts.map +1 -1
- package/dist/lib/forgot_password_config.server.d.ts +2 -2
- package/dist/lib/forgot_password_config.server.d.ts.map +1 -1
- package/dist/lib/login_config.server.d.ts +8 -5
- package/dist/lib/login_config.server.d.ts.map +1 -1
- package/dist/lib/login_config.server.js +13 -6
- package/dist/lib/my_settings_config.server.d.ts.map +1 -1
- package/dist/lib/my_settings_config.server.js +22 -15
- package/dist/lib/navbar_config.server.d.ts +3 -2
- package/dist/lib/navbar_config.server.d.ts.map +1 -1
- package/dist/lib/navbar_config.server.js +4 -2
- package/dist/lib/oauth_config.server.d.ts +6 -6
- package/dist/lib/oauth_config.server.d.ts.map +1 -1
- package/dist/lib/oauth_config.server.js +8 -4
- package/dist/lib/otp_config.server.d.ts +2 -2
- package/dist/lib/otp_config.server.d.ts.map +1 -1
- package/dist/lib/otp_config.server.js +4 -2
- package/dist/lib/profile_pic_menu_config.server.d.ts +6 -2
- package/dist/lib/profile_pic_menu_config.server.d.ts.map +1 -1
- package/dist/lib/profile_pic_menu_config.server.js +5 -3
- package/dist/lib/register_config.server.d.ts +7 -6
- package/dist/lib/register_config.server.d.ts.map +1 -1
- package/dist/lib/register_config.server.js +8 -4
- package/dist/lib/reset_password_config.server.d.ts +6 -4
- package/dist/lib/reset_password_config.server.d.ts.map +1 -1
- package/dist/lib/reset_password_config.server.js +5 -5
- package/dist/lib/services/oauth_service.d.ts.map +1 -1
- package/dist/lib/services/oauth_service.js +13 -0
- package/dist/lib/services/otp_service.d.ts.map +1 -1
- package/dist/lib/services/otp_service.js +6 -0
- package/dist/lib/services/registration_service.d.ts.map +1 -1
- package/dist/lib/services/registration_service.js +7 -0
- package/dist/lib/ui_shell_config.server.d.ts +6 -2
- package/dist/lib/ui_shell_config.server.d.ts.map +1 -1
- package/dist/lib/ui_shell_config.server.js +5 -3
- package/dist/locales/en.json +135 -1
- package/dist/server-lib.d.ts +2 -0
- package/dist/server-lib.d.ts.map +1 -1
- package/dist/server-lib.js +2 -0
- package/dist/server_pages/forgot_password.d.ts +3 -2
- package/dist/server_pages/forgot_password.d.ts.map +1 -1
- package/dist/server_pages/forgot_password.js +8 -7
- package/dist/server_pages/forgot_password_client_wrapper.d.ts +2 -1
- package/dist/server_pages/forgot_password_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/forgot_password_client_wrapper.js +3 -1
- package/dist/server_pages/login.d.ts.map +1 -1
- package/dist/server_pages/login.js +9 -7
- package/dist/server_pages/login_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/login_client_wrapper.js +3 -1
- package/dist/server_pages/otp.d.ts +6 -3
- package/dist/server_pages/otp.d.ts.map +1 -1
- package/dist/server_pages/otp.js +11 -8
- package/dist/server_pages/register.d.ts.map +1 -1
- package/dist/server_pages/register.js +7 -6
- package/dist/server_pages/register_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/register_client_wrapper.js +3 -1
- package/dist/server_pages/reset_password.d.ts.map +1 -1
- package/dist/server_pages/reset_password.js +7 -6
- package/dist/server_pages/reset_password_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/reset_password_client_wrapper.js +3 -1
- package/dist/server_pages/verify_email.d.ts.map +1 -1
- package/dist/server_pages/verify_email.js +6 -5
- package/dist/server_pages/verify_email_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/verify_email_client_wrapper.js +4 -2
- package/dist/strings/default_strings.d.ts +15 -0
- package/dist/strings/default_strings.d.ts.map +1 -1
- package/dist/strings/default_strings.js +53 -0
- package/dist/strings/index.d.ts +1 -1
- package/dist/strings/index.d.ts.map +1 -1
- package/dist/strings/index.js +1 -1
- package/dist/strings/strings_context.d.ts +20 -3
- package/dist/strings/strings_context.d.ts.map +1 -1
- package/dist/strings/strings_context.js +39 -5
- package/dist/strings/strings_provider.d.ts +1 -5
- package/dist/strings/strings_provider.d.ts.map +1 -1
- package/dist/strings/strings_provider.js +5 -1
- package/package.json +10 -6
package/README.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
A reusable authentication UI component package powered by Next.js, TailwindCSS, and shadcn. It integrates `hazo_config` for configuration management and `hazo_connect` for data access, enabling future components to stay aligned with platform conventions.
|
|
4
4
|
|
|
5
|
+
### What's New in v10.22.0
|
|
6
|
+
|
|
7
|
+
- **Signup lifecycle hooks** — `register_auth_hooks({ on_user_created })` (from `hazo_auth/server-lib`) lets your app react to new-user creation (welcome emails, lifecycle sequences, analytics) without hazo_auth depending on your code. Fires best-effort on email registration, Google/Facebook OAuth, and OTP auto-register, passing `{ user_id, email, name?, auth_provider }`. See [Phase 8.2 of SETUP_CHECKLIST.md](SETUP_CHECKLIST.md#phase-82-signup-lifecycle-hooks-setup-optional).
|
|
8
|
+
- **`getLocalizedStrings(t)`** — build a locale-aware `DEFAULT_STRINGS` equivalent from a `hazo_i18n`-sourced `t`, then `setStrings(getLocalizedStrings(t))` in your root layout so server pages reading `readStrings()` render in the active locale.
|
|
9
|
+
- Fixed locale switching not affecting auth-flow text (login/register/forgot-password/reset-password/verify-email/otp/oauth/my_settings/navbar/ui_shell/profile_pic_menu) — see `10.21.0` below for details.
|
|
10
|
+
|
|
5
11
|
### What's New in v10.8.0
|
|
6
12
|
|
|
7
13
|
- **Firm branding gained `app_title` + `footer`.** `FirmBranding` (from `use_firm_branding`) now carries `app_title?: string` and `footer?: { public?: FooterConfig; app?: FooterConfig }` alongside the existing logo/color fields — migration `022_add_app_title_and_footer_to_hazo_scopes.sql` adds the backing `app_title`/`footer_config` columns to `hazo_scopes`. The scope-management branding editor exposes both as new form inputs.
|
package/SETUP_CHECKLIST.md
CHANGED
|
@@ -2219,6 +2219,33 @@ admin issue — same options as `wireAdminIssueCapture` (which it wraps).
|
|
|
2219
2219
|
|
|
2220
2220
|
---
|
|
2221
2221
|
|
|
2222
|
+
## Phase 8.2: Signup Lifecycle Hooks Setup (Optional)
|
|
2223
|
+
|
|
2224
|
+
`register_auth_hooks()` lets your app react to new-user creation (welcome emails, lifecycle
|
|
2225
|
+
sequences, analytics) without hazo_auth depending on your code — hazo_auth calls a callback
|
|
2226
|
+
your app registers, not the other way around.
|
|
2227
|
+
|
|
2228
|
+
**Server-side (once, at boot):**
|
|
2229
|
+
```typescript
|
|
2230
|
+
import { register_auth_hooks } from "hazo_auth/server-lib";
|
|
2231
|
+
|
|
2232
|
+
register_auth_hooks({
|
|
2233
|
+
on_user_created: async ({ user_id, email, name, auth_provider }) => {
|
|
2234
|
+
await scheduleWelcomeEmail({ user_id, email, name, auth_provider });
|
|
2235
|
+
},
|
|
2236
|
+
});
|
|
2237
|
+
```
|
|
2238
|
+
|
|
2239
|
+
`on_user_created` fires fire-and-forget (best-effort) after a user is created via email
|
|
2240
|
+
registration, Google OAuth, Facebook OAuth, or OTP auto-register — `auth_provider` tells you
|
|
2241
|
+
which. A throwing hook is caught and logged; it never blocks or fails signup.
|
|
2242
|
+
|
|
2243
|
+
**Signup Lifecycle Hooks Checklist:**
|
|
2244
|
+
- [ ] `register_auth_hooks({ on_user_created })` called once at server boot
|
|
2245
|
+
- [ ] Hook handler tolerates being called for all four `auth_provider` values (`email`, `google`, `facebook`, `otp`)
|
|
2246
|
+
|
|
2247
|
+
---
|
|
2248
|
+
|
|
2222
2249
|
## Troubleshooting
|
|
2223
2250
|
|
|
2224
2251
|
### Issue: "User is inactive" or "auth_utility_fetch_user_failed" errors
|
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
import "server-only";
|
|
4
4
|
|
|
5
5
|
// section: imports
|
|
6
|
-
import { get_config_value, get_config_boolean } from "./config/config_loader.server.js";
|
|
6
|
+
import { get_config_value, get_config_value_optional, get_config_boolean } from "./config/config_loader.server.js";
|
|
7
7
|
|
|
8
8
|
// section: types
|
|
9
9
|
export type AlreadyLoggedInConfig = {
|
|
10
|
-
|
|
10
|
+
/** Undefined when not configured — components fall back to their own i18n `t()` default. */
|
|
11
|
+
message: string | undefined;
|
|
11
12
|
showLogoutButton: boolean;
|
|
12
13
|
showReturnHomeButton: boolean;
|
|
13
|
-
|
|
14
|
+
/** Undefined when not configured — components fall back to their own i18n `t()` default. */
|
|
15
|
+
returnHomeButtonLabel: string | undefined;
|
|
14
16
|
returnHomePath: string;
|
|
15
17
|
};
|
|
16
18
|
|
|
@@ -23,8 +25,10 @@ export type AlreadyLoggedInConfig = {
|
|
|
23
25
|
export function get_already_logged_in_config(): AlreadyLoggedInConfig {
|
|
24
26
|
const section = "hazo_auth__already_logged_in";
|
|
25
27
|
|
|
26
|
-
// Read message
|
|
27
|
-
|
|
28
|
+
// Read message — undefined when not configured, so the consuming component's
|
|
29
|
+
// own `message ?? t(...)` i18n fallback resolves it instead of a hardcoded
|
|
30
|
+
// English string.
|
|
31
|
+
const message = get_config_value_optional(section, "message");
|
|
28
32
|
|
|
29
33
|
// Read show logout button (defaults to true)
|
|
30
34
|
const showLogoutButton = get_config_boolean(section, "show_logout_button", true);
|
|
@@ -32,8 +36,8 @@ export function get_already_logged_in_config(): AlreadyLoggedInConfig {
|
|
|
32
36
|
// Read show return home button (defaults to false)
|
|
33
37
|
const showReturnHomeButton = get_config_boolean(section, "show_return_home_button", false);
|
|
34
38
|
|
|
35
|
-
// Read return home button label
|
|
36
|
-
const returnHomeButtonLabel =
|
|
39
|
+
// Read return home button label — undefined when not configured, see `message` above.
|
|
40
|
+
const returnHomeButtonLabel = get_config_value_optional(section, "return_home_button_label");
|
|
37
41
|
|
|
38
42
|
// Read return home path (defaults to "/")
|
|
39
43
|
const returnHomePath = get_config_value(section, "return_home_path", "/");
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// file_description: Fire-and-forget hook registry fired on user signup, so consuming apps
|
|
2
|
+
// (e.g. GoTimer's lifecycle email scheduler) can react without hazo_auth depending on them.
|
|
3
|
+
import { create_app_logger } from './app_logger.js';
|
|
4
|
+
|
|
5
|
+
const log = create_app_logger();
|
|
6
|
+
|
|
7
|
+
// section: types
|
|
8
|
+
|
|
9
|
+
export interface AuthHookContext {
|
|
10
|
+
user_id: string;
|
|
11
|
+
email: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
auth_provider: 'email' | 'google' | 'facebook' | 'otp';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface AuthHooks {
|
|
17
|
+
on_user_created?: (ctx: AuthHookContext) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// section: registry
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Module-level registry, set once at app boot by the consuming app.
|
|
24
|
+
* DI: hazo_auth does NOT import the consuming app — the app registers its own callbacks here.
|
|
25
|
+
*/
|
|
26
|
+
let _hooks: AuthHooks = {};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Registers hooks. Additive merge — only overwrites the keys passed in, so
|
|
30
|
+
* multiple call sites can each register different hooks without clobbering each other.
|
|
31
|
+
*/
|
|
32
|
+
export function register_auth_hooks(hooks: AuthHooks): void {
|
|
33
|
+
_hooks = { ..._hooks, ...hooks };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Fires a registered hook by name, best-effort. Never throws or rejects to the
|
|
38
|
+
* caller — signup must succeed even if the hook fails.
|
|
39
|
+
*/
|
|
40
|
+
export async function fire_auth_hook<K extends keyof AuthHooks>(
|
|
41
|
+
name: K,
|
|
42
|
+
ctx: AuthHookContext,
|
|
43
|
+
): Promise<void> {
|
|
44
|
+
const hook = _hooks[name];
|
|
45
|
+
if (!hook) return;
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
await hook(ctx);
|
|
49
|
+
} catch (err) {
|
|
50
|
+
log.warn(`${name} hook failed`, { error: err, user_id: ctx.user_id });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -144,6 +144,40 @@ export function get_config_value_allow_empty(
|
|
|
144
144
|
return section[key].trim();
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Gets a single config value from a section with no forced default — returns
|
|
149
|
+
* `undefined` when the section or key is absent instead of substituting a
|
|
150
|
+
* hardcoded fallback string.
|
|
151
|
+
*
|
|
152
|
+
* Use this for user-visible label/text config keys whose component consumes
|
|
153
|
+
* them with its own `prop ?? t(key)` i18n fallback (e.g. FormHeader labels,
|
|
154
|
+
* OAuth button text). Returning a hardcoded English default here would
|
|
155
|
+
* short-circuit that fallback and defeat locale-aware translation — this
|
|
156
|
+
* helper lets "not configured" flow all the way through the config layer as
|
|
157
|
+
* `undefined` so the component's own `t()` call is what ultimately resolves
|
|
158
|
+
* the text.
|
|
159
|
+
*
|
|
160
|
+
* Preserves get_config_value_allow_empty's "" semantics: a key explicitly set
|
|
161
|
+
* to an empty string in the INI is returned as "" (intentionally empty, e.g.
|
|
162
|
+
* to hide a link), while an absent key returns `undefined` (not configured —
|
|
163
|
+
* defer to the caller's own i18n-aware default).
|
|
164
|
+
* @param section_name - Name of the section
|
|
165
|
+
* @param key - Key name within the section
|
|
166
|
+
* @param file_path - Optional custom config file path
|
|
167
|
+
* @returns Config value as string, "" if key exists but empty, or undefined if key is missing
|
|
168
|
+
*/
|
|
169
|
+
export function get_config_value_optional(
|
|
170
|
+
section_name: string,
|
|
171
|
+
key: string,
|
|
172
|
+
file_path?: string,
|
|
173
|
+
): string | undefined {
|
|
174
|
+
const section = read_config_section(section_name, file_path);
|
|
175
|
+
if (!section || section[key] === undefined) {
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
return section[key].trim();
|
|
179
|
+
}
|
|
180
|
+
|
|
147
181
|
/**
|
|
148
182
|
* Gets a boolean config value from a section
|
|
149
183
|
* @param section_name - Name of the section
|
|
@@ -13,10 +13,10 @@ const DEFAULT_VERIFY_EMAIL_IMAGE_PATH = "/hazo_auth/images/verify_email_default.
|
|
|
13
13
|
|
|
14
14
|
// section: types
|
|
15
15
|
export type EmailVerificationConfig = {
|
|
16
|
-
alreadyLoggedInMessage: string;
|
|
16
|
+
alreadyLoggedInMessage: string | undefined;
|
|
17
17
|
showLogoutButton: boolean;
|
|
18
18
|
showReturnHomeButton: boolean;
|
|
19
|
-
returnHomeButtonLabel: string;
|
|
19
|
+
returnHomeButtonLabel: string | undefined;
|
|
20
20
|
returnHomePath: string;
|
|
21
21
|
imageSrc: string;
|
|
22
22
|
imageAlt: string;
|
|
@@ -13,10 +13,10 @@ const DEFAULT_FORGOT_PASSWORD_IMAGE_PATH = "/hazo_auth/images/forgot_password_de
|
|
|
13
13
|
|
|
14
14
|
// section: types
|
|
15
15
|
export type ForgotPasswordConfig = {
|
|
16
|
-
alreadyLoggedInMessage: string;
|
|
16
|
+
alreadyLoggedInMessage: string | undefined;
|
|
17
17
|
showLogoutButton: boolean;
|
|
18
18
|
showReturnHomeButton: boolean;
|
|
19
|
-
returnHomeButtonLabel: string;
|
|
19
|
+
returnHomeButtonLabel: string | undefined;
|
|
20
20
|
returnHomePath: string;
|
|
21
21
|
imageSrc: string;
|
|
22
22
|
imageAlt: string;
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
import "server-only";
|
|
4
4
|
|
|
5
5
|
// section: imports
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
get_config_value,
|
|
8
|
+
get_config_value_allow_empty,
|
|
9
|
+
get_config_value_optional,
|
|
10
|
+
} from "./config/config_loader.server.js";
|
|
7
11
|
import { get_already_logged_in_config } from "./already_logged_in_config.server.js";
|
|
8
12
|
import { get_oauth_config, type OAuthConfig } from "./oauth_config.server.js";
|
|
9
13
|
|
|
@@ -13,16 +17,19 @@ const DEFAULT_LOGIN_IMAGE_PATH = "/api/hazo_auth/assets/login_default.jpg";
|
|
|
13
17
|
// section: types
|
|
14
18
|
export type LoginConfig = {
|
|
15
19
|
redirectRoute?: string;
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
/** Undefined when not configured — the login component falls back to `t("login.success_message_default")`. */
|
|
21
|
+
successMessage: string | undefined;
|
|
22
|
+
alreadyLoggedInMessage: string | undefined;
|
|
18
23
|
showLogoutButton: boolean;
|
|
19
24
|
showReturnHomeButton: boolean;
|
|
20
|
-
returnHomeButtonLabel: string;
|
|
25
|
+
returnHomeButtonLabel: string | undefined;
|
|
21
26
|
returnHomePath: string;
|
|
22
27
|
forgotPasswordPath: string;
|
|
23
|
-
|
|
28
|
+
/** Undefined when not configured — falls back to `t("login.forgot_password_link_default")`. "" hides the link. */
|
|
29
|
+
forgotPasswordLabel: string | undefined;
|
|
24
30
|
createAccountPath: string;
|
|
25
|
-
|
|
31
|
+
/** Undefined when not configured — falls back to `t("login.create_account_link_default")`. "" hides the link. */
|
|
32
|
+
createAccountLabel: string | undefined;
|
|
26
33
|
showCreateAccountLink: boolean;
|
|
27
34
|
imageSrc: string;
|
|
28
35
|
imageAlt: string;
|
|
@@ -44,26 +51,25 @@ export function get_login_config(): LoginConfig {
|
|
|
44
51
|
const redirectRouteValue = get_config_value(section, "redirect_route_on_successful_login", "");
|
|
45
52
|
const redirectRoute = redirectRouteValue || undefined;
|
|
46
53
|
|
|
47
|
-
// Read success message
|
|
48
|
-
|
|
54
|
+
// Read success message — undefined when not configured, so LoginLayout's own
|
|
55
|
+
// `successMessage ?? t("login.success_message_default")` fallback applies.
|
|
56
|
+
const successMessage = get_config_value_optional(section, "success_message");
|
|
49
57
|
|
|
50
|
-
//
|
|
58
|
+
// Path keeps its allow_empty semantics unchanged: "" in the INI hides the
|
|
59
|
+
// link, an unset key falls back to the default path (not an i18n concern).
|
|
51
60
|
const forgotPasswordPath = get_config_value_allow_empty(
|
|
52
61
|
section,
|
|
53
62
|
"forgot_password_path",
|
|
54
63
|
"/hazo_auth/forgot_password"
|
|
55
64
|
);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
);
|
|
65
|
+
// Undefined when not configured — LoginLayout falls back to
|
|
66
|
+
// `t("login.forgot_password_link_default")`. Explicitly set to "" in the
|
|
67
|
+
// INI still hides the link (get_config_value_optional preserves that).
|
|
68
|
+
const forgotPasswordLabel = get_config_value_optional(section, "forgot_password_label");
|
|
61
69
|
const createAccountPath = get_config_value_allow_empty(section, "create_account_path", "/hazo_auth/register");
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"Create account"
|
|
66
|
-
);
|
|
70
|
+
// Undefined when not configured — LoginLayout falls back to
|
|
71
|
+
// `t("login.create_account_link_default")`. "" still hides the link.
|
|
72
|
+
const createAccountLabel = get_config_value_optional(section, "create_account_label");
|
|
67
73
|
const showCreateAccountLink = get_config_value(section, "show_create_account_link", "true") === "true";
|
|
68
74
|
|
|
69
75
|
// Get shared already logged in config
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import "server-only";
|
|
4
4
|
|
|
5
5
|
// section: imports
|
|
6
|
-
import { get_config_value, get_config_boolean } from "./config/config_loader.server.js";
|
|
6
|
+
import { get_config_value, get_config_value_optional, get_config_boolean } from "./config/config_loader.server.js";
|
|
7
7
|
import { get_user_fields_config } from "./user_fields_config.server.js";
|
|
8
8
|
import { get_password_requirements_config } from "./password_requirements_config.server.js";
|
|
9
9
|
import { get_profile_picture_config } from "./profile_picture_config.server.js";
|
|
@@ -96,21 +96,28 @@ export function get_my_settings_config(): MySettingsConfig {
|
|
|
96
96
|
const uiSizes = get_ui_sizes_config();
|
|
97
97
|
const fileTypes = get_file_types_config();
|
|
98
98
|
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
const
|
|
99
|
+
// Undefined when not configured — MySettingsLayout resolves each of these
|
|
100
|
+
// via its own `prop ?? t(key)` fallback (my_settings.page_title,
|
|
101
|
+
// my_settings.sub_heading_default, my_settings.profile_photo_label_default,
|
|
102
|
+
// etc.), so a hardcoded default here would defeat locale-aware translation.
|
|
103
|
+
const heading = get_config_value_optional(section, "heading");
|
|
104
|
+
const subHeading = get_config_value_optional(section, "sub_heading");
|
|
105
|
+
const profilePhotoLabel = get_config_value_optional(section, "profile_photo_label");
|
|
106
|
+
const profilePhotoRecommendation = get_config_value_optional(section, "profile_photo_recommendation");
|
|
107
|
+
const uploadPhotoButtonLabel = get_config_value_optional(section, "upload_photo_button_label");
|
|
108
|
+
const removePhotoButtonLabel = get_config_value_optional(section, "remove_photo_button_label");
|
|
109
|
+
const profileInformationLabel = get_config_value_optional(section, "profile_information_label");
|
|
110
|
+
const passwordLabel = get_config_value_optional(section, "password_label");
|
|
111
|
+
const currentPasswordLabel = get_config_value_optional(section, "current_password_label");
|
|
112
|
+
const newPasswordLabel = get_config_value_optional(section, "new_password_label");
|
|
113
|
+
const confirmPasswordLabel = get_config_value_optional(section, "confirm_password_label");
|
|
114
|
+
// NOTE: savePasswordButtonLabel is read here but is not currently consumed
|
|
115
|
+
// by MySettingsLayout (the save-password button renders `t(...)` directly,
|
|
116
|
+
// ignoring this prop) — left as a hardcoded default since there is no
|
|
117
|
+
// fallback to defeat; out of scope for this fix.
|
|
111
118
|
const savePasswordButtonLabel = get_config_value(section, "save_password_button_label", "Save Password");
|
|
112
|
-
const unauthorizedMessage =
|
|
113
|
-
const loginButtonLabel =
|
|
119
|
+
const unauthorizedMessage = get_config_value_optional(section, "unauthorized_message");
|
|
120
|
+
const loginButtonLabel = get_config_value_optional(section, "login_button_label");
|
|
114
121
|
const loginPath = get_config_value(section, "login_path", "/hazo_auth/login");
|
|
115
122
|
const enableAccountDeletion = get_config_boolean(section, "enable_account_deletion", false);
|
|
116
123
|
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
import "server-only";
|
|
4
4
|
|
|
5
5
|
// section: imports
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
get_config_value,
|
|
8
|
+
get_config_boolean,
|
|
9
|
+
get_config_number,
|
|
10
|
+
get_config_value_optional,
|
|
11
|
+
} from "./config/config_loader.server.js";
|
|
7
12
|
import { DEFAULT_NAVBAR } from "./config/default_config.js";
|
|
8
13
|
|
|
9
14
|
// section: types
|
|
@@ -20,8 +25,9 @@ export type NavbarConfig = {
|
|
|
20
25
|
company_name: string;
|
|
21
26
|
/** Home link path */
|
|
22
27
|
home_path: string;
|
|
23
|
-
/** Home link label
|
|
24
|
-
|
|
28
|
+
/** Home link label. Undefined when not configured — the navbar component
|
|
29
|
+
* falls back to `t("navbar.home_label_default")`. */
|
|
30
|
+
home_label: string | undefined;
|
|
25
31
|
/** Show home link */
|
|
26
32
|
show_home_link: boolean;
|
|
27
33
|
/** Navbar background color (empty = inherit) */
|
|
@@ -78,11 +84,9 @@ export function get_navbar_config(): NavbarConfig {
|
|
|
78
84
|
DEFAULT_NAVBAR.home_path
|
|
79
85
|
);
|
|
80
86
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
DEFAULT_NAVBAR.home_label
|
|
85
|
-
);
|
|
87
|
+
// Undefined when not configured — AuthNavbar falls back to
|
|
88
|
+
// `t("navbar.home_label_default")`.
|
|
89
|
+
const home_label = get_config_value_optional(SECTION_NAME, "home_label");
|
|
86
90
|
|
|
87
91
|
const show_home_link = get_config_boolean(
|
|
88
92
|
SECTION_NAME,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import "server-only";
|
|
4
4
|
|
|
5
5
|
// section: imports
|
|
6
|
-
import { get_config_value, get_config_boolean } from "./config/config_loader.server.js";
|
|
6
|
+
import { get_config_value, get_config_value_optional, get_config_boolean } from "./config/config_loader.server.js";
|
|
7
7
|
import { DEFAULT_OAUTH } from "./config/default_config.js";
|
|
8
8
|
|
|
9
9
|
// section: types
|
|
@@ -14,10 +14,10 @@ export type OAuthConfig = {
|
|
|
14
14
|
enable_email_password: boolean;
|
|
15
15
|
/** Auto-link Google login to existing unverified email/password accounts */
|
|
16
16
|
auto_link_unverified_accounts: boolean;
|
|
17
|
-
/** Text displayed on the Google sign-in button */
|
|
18
|
-
google_button_text: string;
|
|
19
|
-
/** Text displayed on the divider between OAuth and email/password form */
|
|
20
|
-
oauth_divider_text: string;
|
|
17
|
+
/** Text displayed on the Google sign-in button. Undefined when not configured — the login/register components fall back to their own `t()` default. */
|
|
18
|
+
google_button_text: string | undefined;
|
|
19
|
+
/** Text displayed on the divider between OAuth and email/password form. Undefined when not configured — falls back to `t("shared.oauth_divider_default")`. */
|
|
20
|
+
oauth_divider_text: string | undefined;
|
|
21
21
|
/** NextAuth signIn page path */
|
|
22
22
|
sign_in_page: string;
|
|
23
23
|
/** NextAuth error page path */
|
|
@@ -36,8 +36,8 @@ export type OAuthConfig = {
|
|
|
36
36
|
facebook_app_id: string;
|
|
37
37
|
/** Facebook App Secret (env: HAZO_AUTH_FACEBOOK_APP_SECRET overrides config) */
|
|
38
38
|
facebook_app_secret: string;
|
|
39
|
-
/** Text displayed on the Facebook sign-in button */
|
|
40
|
-
facebook_button_text: string;
|
|
39
|
+
/** Text displayed on the Facebook sign-in button. Undefined when not configured — falls back to `t("shared.oauth.facebook_button_default")`. */
|
|
40
|
+
facebook_button_text: string | undefined;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
// section: constants
|
|
@@ -68,17 +68,11 @@ export function get_oauth_config(): OAuthConfig {
|
|
|
68
68
|
DEFAULT_OAUTH.auto_link_unverified_accounts
|
|
69
69
|
);
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
DEFAULT_OAUTH.google_button_text
|
|
75
|
-
);
|
|
71
|
+
// Undefined when not configured — the login/register layout components fall
|
|
72
|
+
// back to their own locale-aware `t()` default instead of a hardcoded string.
|
|
73
|
+
const google_button_text = get_config_value_optional(SECTION_NAME, "google_button_text");
|
|
76
74
|
|
|
77
|
-
const oauth_divider_text =
|
|
78
|
-
SECTION_NAME,
|
|
79
|
-
"oauth_divider_text",
|
|
80
|
-
DEFAULT_OAUTH.oauth_divider_text
|
|
81
|
-
);
|
|
75
|
+
const oauth_divider_text = get_config_value_optional(SECTION_NAME, "oauth_divider_text");
|
|
82
76
|
|
|
83
77
|
const sign_in_page = get_config_value(
|
|
84
78
|
SECTION_NAME,
|
|
@@ -130,11 +124,9 @@ export function get_oauth_config(): OAuthConfig {
|
|
|
130
124
|
process.env.HAZO_AUTH_FACEBOOK_APP_SECRET ||
|
|
131
125
|
get_config_value(SECTION_NAME, "facebook_app_secret", "");
|
|
132
126
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
"Continue with Facebook"
|
|
137
|
-
);
|
|
127
|
+
// Undefined when not configured — GoogleSignInButton/FacebookSignInButton
|
|
128
|
+
// callers fall back to `t("shared.oauth.facebook_button_default")`.
|
|
129
|
+
const facebook_button_text = get_config_value_optional(SECTION_NAME, "facebook_button_text");
|
|
138
130
|
|
|
139
131
|
return {
|
|
140
132
|
enable_google,
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
import "server-only";
|
|
4
4
|
|
|
5
5
|
// section: imports
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
get_config_value,
|
|
8
|
+
get_config_value_optional,
|
|
9
|
+
get_config_boolean,
|
|
10
|
+
get_config_number,
|
|
11
|
+
} from "./config/config_loader.server.js";
|
|
7
12
|
|
|
8
13
|
// section: defaults
|
|
9
14
|
export const OTP_CONFIG_DEFAULTS = {
|
|
@@ -51,8 +56,8 @@ export type OtpConfig = {
|
|
|
51
56
|
auto_assign_role_name: string;
|
|
52
57
|
/** Image shown in the OTP page's visual panel */
|
|
53
58
|
image_src: string;
|
|
54
|
-
/** Alt text for the OTP page's visual panel image */
|
|
55
|
-
image_alt: string;
|
|
59
|
+
/** Alt text for the OTP page's visual panel image. Undefined when not configured — OTPLayout falls back to `t("otp.layout.image_alt")`. */
|
|
60
|
+
image_alt: string | undefined;
|
|
56
61
|
};
|
|
57
62
|
|
|
58
63
|
// section: helpers
|
|
@@ -89,7 +94,9 @@ export function get_otp_config(): OtpConfig {
|
|
|
89
94
|
auto_assign_scope_id: get_config_value(section, "otp_auto_assign_scope_id", d.auto_assign_scope_id),
|
|
90
95
|
auto_assign_role_name: get_config_value(section, "otp_auto_assign_role_name", d.auto_assign_role_name),
|
|
91
96
|
image_src: get_config_value(section, "otp_image_src", d.image_src),
|
|
92
|
-
|
|
97
|
+
// Undefined when not configured — OTPLayout falls back to
|
|
98
|
+
// `t("otp.layout.image_alt")` for locale-aware alt text.
|
|
99
|
+
image_alt: get_config_value_optional(section, "otp_image_alt"),
|
|
93
100
|
};
|
|
94
101
|
}
|
|
95
102
|
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
import "server-only";
|
|
4
4
|
|
|
5
5
|
// section: imports
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
get_config_value,
|
|
8
|
+
get_config_boolean,
|
|
9
|
+
get_config_array,
|
|
10
|
+
get_config_value_optional,
|
|
11
|
+
} from "./config/config_loader.server.js";
|
|
7
12
|
|
|
8
13
|
// section: types
|
|
9
14
|
// Note: These types are also used in client components, but TypeScript types are erased at runtime
|
|
@@ -22,8 +27,12 @@ export type ProfilePicMenuMenuItem = {
|
|
|
22
27
|
|
|
23
28
|
export type ProfilePicMenuConfig = {
|
|
24
29
|
show_single_button: boolean;
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
/** Undefined when not configured — ProfilePicMenu falls back to
|
|
31
|
+
* `t("profile_pic_menu.sign_up_label_default")`. */
|
|
32
|
+
sign_up_label: string | undefined;
|
|
33
|
+
/** Undefined when not configured — ProfilePicMenu falls back to
|
|
34
|
+
* `t("profile_pic_menu.sign_in_label_default")`. */
|
|
35
|
+
sign_in_label: string | undefined;
|
|
27
36
|
register_path: string;
|
|
28
37
|
login_path: string;
|
|
29
38
|
settings_path: string;
|
|
@@ -115,8 +124,10 @@ export function get_profile_pic_menu_config(): ProfilePicMenuConfig {
|
|
|
115
124
|
|
|
116
125
|
// Read button configuration
|
|
117
126
|
const show_single_button = get_config_boolean(section, "show_single_button", false);
|
|
118
|
-
|
|
119
|
-
|
|
127
|
+
// Undefined when not configured — ProfilePicMenu falls back to
|
|
128
|
+
// `t("profile_pic_menu.sign_up_label_default")` / `t("profile_pic_menu.sign_in_label_default")`.
|
|
129
|
+
const sign_up_label = get_config_value_optional(section, "sign_up_label");
|
|
130
|
+
const sign_in_label = get_config_value_optional(section, "sign_in_label");
|
|
120
131
|
const register_path = get_config_value(section, "register_path", "/hazo_auth/register");
|
|
121
132
|
const login_path = get_config_value(section, "login_path", "/hazo_auth/login");
|
|
122
133
|
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
import "server-only";
|
|
4
4
|
|
|
5
5
|
// section: imports
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
get_config_boolean,
|
|
8
|
+
get_config_value,
|
|
9
|
+
get_config_value_optional,
|
|
10
|
+
read_config_section,
|
|
11
|
+
} from "./config/config_loader.server.js";
|
|
7
12
|
import { get_password_requirements_config } from "./password_requirements_config.server.js";
|
|
8
13
|
import { get_already_logged_in_config } from "./already_logged_in_config.server.js";
|
|
9
14
|
import { get_user_fields_config } from "./user_fields_config.server.js";
|
|
@@ -24,13 +29,14 @@ export type RegisterConfig = {
|
|
|
24
29
|
require_number: boolean;
|
|
25
30
|
require_special: boolean;
|
|
26
31
|
};
|
|
27
|
-
alreadyLoggedInMessage: string;
|
|
32
|
+
alreadyLoggedInMessage: string | undefined;
|
|
28
33
|
showLogoutButton: boolean;
|
|
29
34
|
showReturnHomeButton: boolean;
|
|
30
|
-
returnHomeButtonLabel: string;
|
|
35
|
+
returnHomeButtonLabel: string | undefined;
|
|
31
36
|
returnHomePath: string;
|
|
32
37
|
signInPath: string;
|
|
33
|
-
|
|
38
|
+
/** Undefined when not configured — RegisterLayout falls back to `t("shared.sign_in_default")`. */
|
|
39
|
+
signInLabel: string | undefined;
|
|
34
40
|
imageSrc: string;
|
|
35
41
|
imageAlt: string;
|
|
36
42
|
imageBackgroundColor: string;
|
|
@@ -38,10 +44,10 @@ export type RegisterConfig = {
|
|
|
38
44
|
oauth: {
|
|
39
45
|
enable_google: boolean;
|
|
40
46
|
enable_email_password: boolean;
|
|
41
|
-
google_button_text: string;
|
|
42
|
-
oauth_divider_text: string;
|
|
47
|
+
google_button_text: string | undefined;
|
|
48
|
+
oauth_divider_text: string | undefined;
|
|
43
49
|
enable_facebook_oauth: boolean;
|
|
44
|
-
facebook_button_text: string;
|
|
50
|
+
facebook_button_text: string | undefined;
|
|
45
51
|
};
|
|
46
52
|
};
|
|
47
53
|
|
|
@@ -73,11 +79,9 @@ export function get_register_config(): RegisterConfig {
|
|
|
73
79
|
"sign_in_path",
|
|
74
80
|
"/hazo_auth/login"
|
|
75
81
|
);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"Sign in"
|
|
80
|
-
);
|
|
82
|
+
// Undefined when not configured — RegisterLayout falls back to
|
|
83
|
+
// `t("shared.sign_in_default")` for locale-aware text.
|
|
84
|
+
const signInLabel = get_config_value_optional("hazo_auth__register_layout", "sign_in_label");
|
|
81
85
|
|
|
82
86
|
// Read image configuration
|
|
83
87
|
// If not set in config, falls back to default path-based image
|
|
@@ -102,11 +106,12 @@ export function get_register_config(): RegisterConfig {
|
|
|
102
106
|
// Get OAuth configuration (shared with login)
|
|
103
107
|
const oauthConfig = get_oauth_config();
|
|
104
108
|
|
|
105
|
-
// For the register page,
|
|
106
|
-
|
|
109
|
+
// For the register page, the Google button text is undefined unless the
|
|
110
|
+
// consumer explicitly overrides it — RegisterLayout falls back to
|
|
111
|
+
// `t("register.oauth.google_button_default")` ("Sign up with Google").
|
|
112
|
+
const registerGoogleButtonText = get_config_value_optional(
|
|
107
113
|
"hazo_auth__oauth",
|
|
108
|
-
"google_button_text_register"
|
|
109
|
-
"Sign up with Google"
|
|
114
|
+
"google_button_text_register"
|
|
110
115
|
);
|
|
111
116
|
|
|
112
117
|
return {
|