hazo_auth 5.1.4 → 5.1.7
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 +12 -0
- package/cli-src/cli/init_users.ts +8 -42
- package/cli-src/lib/auth/auth_cache.ts +9 -8
- package/cli-src/lib/auth/hazo_get_auth.server.ts +36 -19
- package/cli-src/lib/auth/index.ts +1 -1
- package/cli-src/lib/index.ts +3 -3
- package/cli-src/lib/services/index.ts +20 -20
- package/dist/cli/init_users.d.ts.map +1 -1
- package/dist/cli/init_users.js +7 -37
- package/dist/client.d.ts +7 -7
- package/dist/client.js +7 -7
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +2 -2
- package/dist/components/layouts/create_firm/index.d.ts +1 -1
- package/dist/components/layouts/create_firm/index.js +7 -7
- package/dist/components/layouts/dev_lock/index.js +2 -2
- package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts +1 -1
- package/dist/components/layouts/email_verification/config/email_verification_field_config.js +1 -1
- package/dist/components/layouts/email_verification/hooks/use_email_verification.d.ts +1 -1
- package/dist/components/layouts/email_verification/hooks/use_email_verification.js +3 -3
- package/dist/components/layouts/email_verification/index.d.ts +3 -3
- package/dist/components/layouts/email_verification/index.js +9 -9
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts +1 -1
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.js +1 -1
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts +1 -1
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.js +3 -3
- package/dist/components/layouts/forgot_password/index.d.ts +2 -2
- package/dist/components/layouts/forgot_password/index.js +9 -9
- package/dist/components/layouts/index.d.ts +9 -9
- package/dist/components/layouts/index.js +9 -9
- package/dist/components/layouts/login/config/login_field_config.d.ts +1 -1
- package/dist/components/layouts/login/config/login_field_config.js +1 -1
- package/dist/components/layouts/login/hooks/use_login_form.d.ts +1 -1
- package/dist/components/layouts/login/hooks/use_login_form.js +5 -5
- package/dist/components/layouts/login/index.d.ts +2 -2
- package/dist/components/layouts/login/index.js +11 -11
- package/dist/components/layouts/my_settings/components/connected_accounts_section.js +1 -1
- package/dist/components/layouts/my_settings/components/editable_field.js +3 -3
- package/dist/components/layouts/my_settings/components/password_change_dialog.js +4 -4
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.js +8 -8
- package/dist/components/layouts/my_settings/components/profile_picture_display.js +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.js +3 -3
- package/dist/components/layouts/my_settings/components/profile_picture_library_tab.js +6 -6
- package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.js +4 -4
- package/dist/components/layouts/my_settings/components/set_password_section.js +4 -4
- package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts +1 -1
- package/dist/components/layouts/my_settings/config/my_settings_field_config.js +1 -1
- package/dist/components/layouts/my_settings/hooks/use_my_settings.js +2 -2
- package/dist/components/layouts/my_settings/index.d.ts +1 -1
- package/dist/components/layouts/my_settings/index.js +12 -12
- package/dist/components/layouts/register/config/register_field_config.d.ts +1 -1
- package/dist/components/layouts/register/config/register_field_config.js +1 -1
- package/dist/components/layouts/register/hooks/use_register_form.d.ts +1 -1
- package/dist/components/layouts/register/hooks/use_register_form.js +3 -3
- package/dist/components/layouts/register/index.d.ts +2 -2
- package/dist/components/layouts/register/index.js +9 -9
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts +1 -1
- package/dist/components/layouts/reset_password/config/reset_password_field_config.js +1 -1
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.d.ts +1 -1
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.js +3 -3
- package/dist/components/layouts/reset_password/index.d.ts +2 -2
- package/dist/components/layouts/reset_password/index.js +8 -8
- package/dist/components/layouts/scope_management/components/branding_editor.js +5 -5
- package/dist/components/layouts/shared/components/already_logged_in_guard.js +4 -4
- package/dist/components/layouts/shared/components/auth_navbar.js +1 -1
- package/dist/components/layouts/shared/components/auth_page_shell.js +3 -3
- package/dist/components/layouts/shared/components/form_action_buttons.js +1 -1
- package/dist/components/layouts/shared/components/form_field_wrapper.js +2 -2
- package/dist/components/layouts/shared/components/google_sign_in_button.js +3 -3
- package/dist/components/layouts/shared/components/logout_button.js +3 -3
- package/dist/components/layouts/shared/components/oauth_divider.js +1 -1
- package/dist/components/layouts/shared/components/password_field.js +3 -3
- package/dist/components/layouts/shared/components/profile_pic_menu.js +8 -8
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.js +2 -2
- package/dist/components/layouts/shared/components/profile_stamp.js +3 -3
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.js +3 -3
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.d.ts +1 -1
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.js +2 -2
- package/dist/components/layouts/shared/components/two_column_auth_layout.js +1 -1
- package/dist/components/layouts/shared/components/unauthorized_guard.js +2 -2
- package/dist/components/layouts/shared/hooks/use_auth_status.js +1 -1
- package/dist/components/layouts/shared/hooks/use_firm_branding.js +1 -1
- package/dist/components/layouts/shared/hooks/use_hazo_auth.js +1 -1
- package/dist/components/layouts/shared/index.d.ts +23 -23
- package/dist/components/layouts/shared/index.js +23 -23
- package/dist/components/layouts/user_management/components/app_user_data_editor.js +5 -5
- package/dist/components/layouts/user_management/components/roles_matrix.js +8 -8
- package/dist/components/layouts/user_management/components/scope_hierarchy_tab.js +9 -9
- package/dist/components/layouts/user_management/components/user_scopes_tab.js +9 -9
- package/dist/components/layouts/user_management/index.js +17 -17
- package/dist/components/ui/alert-dialog.js +2 -2
- package/dist/components/ui/avatar.js +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/card.js +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/dropdown-menu.js +1 -1
- package/dist/components/ui/hazo_ui_tooltip.js +1 -1
- package/dist/components/ui/hover-card.js +1 -1
- package/dist/components/ui/index.d.ts +20 -20
- package/dist/components/ui/index.js +20 -20
- package/dist/components/ui/input.js +1 -1
- package/dist/components/ui/label.js +1 -1
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/separator.js +1 -1
- package/dist/components/ui/sheet.js +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/sidebar.js +8 -8
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/table.js +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/tooltip.js +1 -1
- package/dist/components/ui/tree-view.js +1 -1
- package/dist/components/ui/user-type-badge.js +1 -1
- package/dist/components/ui/vertical-tabs.js +1 -1
- package/dist/contexts/hazo_auth_provider.d.ts +1 -1
- package/dist/contexts/hazo_auth_provider.js +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/lib/already_logged_in_config.server.js +1 -1
- package/dist/lib/app_permissions_config.server.js +1 -1
- package/dist/lib/app_user_data_config.server.js +1 -1
- package/dist/lib/auth/auth_cache.d.ts +7 -6
- package/dist/lib/auth/auth_cache.d.ts.map +1 -1
- package/dist/lib/auth/auth_cache.js +3 -3
- package/dist/lib/auth/auth_utils.server.js +3 -3
- package/dist/lib/auth/dev_lock_validator.edge.js +1 -1
- package/dist/lib/auth/hazo_get_auth.server.d.ts.map +1 -1
- package/dist/lib/auth/hazo_get_auth.server.js +39 -27
- package/dist/lib/auth/index.d.ts +6 -6
- package/dist/lib/auth/index.js +6 -6
- package/dist/lib/auth/nextauth_config.js +4 -4
- package/dist/lib/auth/server_auth.js +3 -3
- package/dist/lib/auth/session_token_validator.edge.js +1 -1
- package/dist/lib/auth_utility_config.server.js +1 -1
- package/dist/lib/branding_config.server.js +1 -1
- package/dist/lib/config/config_loader.server.js +1 -1
- package/dist/lib/cookies_config.server.js +1 -1
- package/dist/lib/dev_lock_config.server.js +2 -2
- package/dist/lib/email_verification_config.server.js +2 -2
- package/dist/lib/file_types_config.server.js +1 -1
- package/dist/lib/forgot_password_config.server.js +2 -2
- package/dist/lib/hazo_connect_instance.server.js +2 -2
- package/dist/lib/hazo_connect_setup.server.js +2 -2
- package/dist/lib/index.d.ts +28 -28
- package/dist/lib/index.js +28 -28
- package/dist/lib/login_config.server.d.ts +1 -1
- package/dist/lib/login_config.server.js +3 -3
- package/dist/lib/messages_config.server.js +1 -1
- package/dist/lib/my_settings_config.server.js +7 -7
- package/dist/lib/navbar_config.server.js +2 -2
- package/dist/lib/oauth_config.server.js +2 -2
- package/dist/lib/password_requirements_config.server.js +2 -2
- package/dist/lib/profile_pic_menu_config.server.js +1 -1
- package/dist/lib/profile_picture_config.server.js +2 -2
- package/dist/lib/register_config.server.js +4 -4
- package/dist/lib/reset_password_config.server.js +3 -3
- package/dist/lib/scope_hierarchy_config.server.js +2 -2
- package/dist/lib/services/app_user_data_service.js +4 -4
- package/dist/lib/services/branding_service.d.ts +1 -1
- package/dist/lib/services/branding_service.js +3 -3
- package/dist/lib/services/email_service.js +2 -2
- package/dist/lib/services/email_verification_service.js +3 -3
- package/dist/lib/services/firm_service.d.ts +2 -2
- package/dist/lib/services/firm_service.js +4 -4
- package/dist/lib/services/index.d.ts +20 -20
- package/dist/lib/services/index.js +20 -20
- package/dist/lib/services/invitation_service.js +4 -4
- package/dist/lib/services/login_service.js +3 -3
- package/dist/lib/services/oauth_service.js +4 -4
- package/dist/lib/services/password_change_service.js +3 -3
- package/dist/lib/services/password_reset_service.js +3 -3
- package/dist/lib/services/post_verification_service.js +4 -4
- package/dist/lib/services/profile_picture_remove_service.js +3 -3
- package/dist/lib/services/profile_picture_service.d.ts +1 -1
- package/dist/lib/services/profile_picture_service.js +5 -5
- package/dist/lib/services/registration_service.js +9 -9
- package/dist/lib/services/scope_service.js +2 -2
- package/dist/lib/services/session_token_service.js +2 -2
- package/dist/lib/services/token_service.js +2 -2
- package/dist/lib/services/user_profiles_service.js +4 -4
- package/dist/lib/services/user_scope_service.js +3 -3
- package/dist/lib/services/user_update_service.d.ts +1 -1
- package/dist/lib/services/user_update_service.js +4 -4
- package/dist/lib/ui_shell_config.server.d.ts +1 -1
- package/dist/lib/ui_shell_config.server.js +2 -2
- package/dist/lib/ui_sizes_config.server.js +1 -1
- package/dist/lib/user_fields_config.server.js +1 -1
- package/dist/lib/user_management_config.server.js +1 -1
- package/dist/lib/user_profiles_config.server.js +1 -1
- package/dist/lib/user_types_config.server.js +2 -2
- package/dist/lib/utils/error_sanitizer.d.ts +1 -1
- package/dist/page_components/create_firm.js +3 -3
- package/dist/page_components/dev_lock.d.ts +1 -1
- package/dist/page_components/dev_lock.d.ts.map +1 -1
- package/dist/page_components/dev_lock.js +1 -1
- package/dist/page_components/forgot_password.js +3 -3
- package/dist/page_components/login.js +3 -3
- package/dist/page_components/my_settings.js +1 -1
- package/dist/page_components/register.js +3 -3
- package/dist/page_components/reset_password.js +3 -3
- package/dist/page_components/verify_email.js +3 -3
- package/dist/server/index.js +1 -1
- package/dist/server/routes/app_user_data.js +5 -5
- package/dist/server/routes/change_password.js +7 -7
- package/dist/server/routes/create_firm.js +6 -6
- package/dist/server/routes/forgot_password.js +4 -4
- package/dist/server/routes/get_auth.js +4 -4
- package/dist/server/routes/invalidate_cache.js +5 -5
- package/dist/server/routes/invitations.js +6 -6
- package/dist/server/routes/library_photo.js +3 -3
- package/dist/server/routes/library_photos.js +3 -3
- package/dist/server/routes/login.js +7 -7
- package/dist/server/routes/logout.js +5 -5
- package/dist/server/routes/me.js +6 -6
- package/dist/server/routes/profile_picture_filename.js +1 -1
- package/dist/server/routes/register.js +5 -5
- package/dist/server/routes/remove_profile_picture.js +4 -4
- package/dist/server/routes/resend_verification.js +4 -4
- package/dist/server/routes/reset_password.js +5 -5
- package/dist/server/routes/update_user.js +6 -6
- package/dist/server/routes/upload_profile_picture.js +7 -7
- package/dist/server/routes/user_management_permissions.js +4 -4
- package/dist/server/routes/user_management_roles.d.ts.map +1 -1
- package/dist/server/routes/user_management_roles.js +17 -15
- package/dist/server/routes/user_management_users.js +7 -7
- package/dist/server/routes/user_management_users_roles.d.ts +12 -5
- package/dist/server/routes/user_management_users_roles.d.ts.map +1 -1
- package/dist/server/routes/user_management_users_roles.js +118 -89
- package/dist/server/routes/validate_reset_token.js +4 -4
- package/dist/server/routes/verify_email.js +5 -5
- package/dist/server/server.js +2 -2
- package/dist/server_pages/forgot_password.js +4 -4
- package/dist/server_pages/forgot_password_client_wrapper.js +3 -3
- package/dist/server_pages/index.d.ts +6 -6
- package/dist/server_pages/index.js +6 -6
- package/dist/server_pages/login.js +3 -3
- package/dist/server_pages/login_client_wrapper.d.ts +1 -1
- package/dist/server_pages/login_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/login_client_wrapper.js +3 -3
- package/dist/server_pages/my_settings.js +3 -3
- package/dist/server_pages/register.js +3 -3
- package/dist/server_pages/register_client_wrapper.js +3 -3
- package/dist/server_pages/reset_password.js +3 -3
- package/dist/server_pages/reset_password_client_wrapper.js +3 -3
- package/dist/server_pages/verify_email.js +4 -4
- package/dist/server_pages/verify_email_client_wrapper.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
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 v5.1.5 🐛
|
|
6
|
+
|
|
7
|
+
**CRITICAL BUGFIX**: Fixed incomplete migration from v4.x to v5.x - several files were still referencing the deprecated `hazo_user_roles` table instead of `hazo_user_scopes`. This release completes the scope-based role assignment architecture introduced in v5.0.
|
|
8
|
+
|
|
9
|
+
**Key Fixes:**
|
|
10
|
+
- ✅ **hazo_get_auth** - Now correctly fetches roles from `hazo_user_scopes`
|
|
11
|
+
- ✅ **Role IDs** - Changed from `number[]` to `string[]` (UUIDs) throughout codebase
|
|
12
|
+
- ✅ **User Management** - Updated for scope-based role assignments
|
|
13
|
+
- ✅ **Cache System** - Fixed type inconsistencies with UUID role IDs
|
|
14
|
+
|
|
15
|
+
If you're on v5.x and experiencing permission/role issues, upgrade to v5.1.5 immediately.
|
|
16
|
+
|
|
5
17
|
### What's New in v5.0 🚀
|
|
6
18
|
|
|
7
19
|
**BREAKING CHANGE: Scope-Based Multi-Tenancy** - Complete architectural redesign for simpler, more flexible multi-tenancy!
|
|
@@ -22,10 +22,7 @@ type InitSummary = {
|
|
|
22
22
|
inserted: number;
|
|
23
23
|
existing: number;
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
inserted: boolean;
|
|
27
|
-
existing: boolean;
|
|
28
|
-
};
|
|
25
|
+
// v5.x: Removed user_role - roles are now assigned via hazo_user_scopes
|
|
29
26
|
super_admin_scope: {
|
|
30
27
|
inserted: boolean;
|
|
31
28
|
existing: boolean;
|
|
@@ -78,15 +75,7 @@ function print_summary(summary: InitSummary): void {
|
|
|
78
75
|
}
|
|
79
76
|
console.log();
|
|
80
77
|
|
|
81
|
-
// User
|
|
82
|
-
console.log("User-Role Assignment:");
|
|
83
|
-
if (summary.user_role.inserted) {
|
|
84
|
-
console.log(` ✓ Inserted: Super user role assigned to user`);
|
|
85
|
-
}
|
|
86
|
-
if (summary.user_role.existing) {
|
|
87
|
-
console.log(` ⊙ Already existed: User already has super user role`);
|
|
88
|
-
}
|
|
89
|
-
console.log();
|
|
78
|
+
// v5.x: User-Role assignments are now handled via User-Scope assignments (see below)
|
|
90
79
|
|
|
91
80
|
// Super admin scope summary
|
|
92
81
|
console.log("Super Admin Scope:");
|
|
@@ -141,10 +130,7 @@ export async function handle_init_users(options: InitUsersOptions = {}): Promise
|
|
|
141
130
|
inserted: 0,
|
|
142
131
|
existing: 0,
|
|
143
132
|
},
|
|
144
|
-
|
|
145
|
-
inserted: false,
|
|
146
|
-
existing: false,
|
|
147
|
-
},
|
|
133
|
+
// v5.x: Removed user_role - roles are now assigned via hazo_user_scopes
|
|
148
134
|
super_admin_scope: {
|
|
149
135
|
inserted: false,
|
|
150
136
|
existing: false,
|
|
@@ -165,7 +151,7 @@ export async function handle_init_users(options: InitUsersOptions = {}): Promise
|
|
|
165
151
|
const roles_service = createCrudService(hazoConnect, "hazo_roles");
|
|
166
152
|
const role_permissions_service = createCrudService(hazoConnect, "hazo_role_permissions");
|
|
167
153
|
const users_service = createCrudService(hazoConnect, "hazo_users");
|
|
168
|
-
|
|
154
|
+
// v5.x: Removed hazo_user_roles - roles are now assigned via hazo_user_scopes
|
|
169
155
|
const scopes_service = createCrudService(hazoConnect, "hazo_scopes");
|
|
170
156
|
// hazo_user_scopes uses composite primary key (user_id, scope_id), no 'id' column
|
|
171
157
|
const user_scopes_service = createCrudService(hazoConnect, "hazo_user_scopes", {
|
|
@@ -328,27 +314,7 @@ export async function handle_init_users(options: InitUsersOptions = {}): Promise
|
|
|
328
314
|
console.log(`✓ Found user: ${super_user_email} (ID: ${user_id})`);
|
|
329
315
|
console.log();
|
|
330
316
|
|
|
331
|
-
//
|
|
332
|
-
const existing_user_roles = await user_roles_service.findBy({
|
|
333
|
-
user_id,
|
|
334
|
-
role_id,
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
if (Array.isArray(existing_user_roles) && existing_user_roles.length > 0) {
|
|
338
|
-
summary.user_role.existing = true;
|
|
339
|
-
console.log(`✓ User already has role assigned: ${user_id} -> ${role_name}`);
|
|
340
|
-
} else {
|
|
341
|
-
await user_roles_service.insert({
|
|
342
|
-
user_id,
|
|
343
|
-
role_id,
|
|
344
|
-
created_at: now,
|
|
345
|
-
changed_at: now,
|
|
346
|
-
});
|
|
347
|
-
summary.user_role.inserted = true;
|
|
348
|
-
console.log(`✓ Assigned role to user: ${user_id} -> ${role_name}`);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
console.log();
|
|
317
|
+
// v5.x: Step 7 removed - role assignment now happens via hazo_user_scopes (see step 9)
|
|
352
318
|
|
|
353
319
|
// 8. Ensure super admin scope exists
|
|
354
320
|
const existing_scopes = await scopes_service.findBy({ id: SUPER_ADMIN_SCOPE_ID });
|
|
@@ -440,9 +406,9 @@ This command reads from hazo_auth_config.ini and:
|
|
|
440
406
|
2. Creates a 'default_super_user_role' role
|
|
441
407
|
3. Assigns all permissions to the super user role
|
|
442
408
|
4. Finds user by email (from --email parameter or config)
|
|
443
|
-
5.
|
|
444
|
-
6.
|
|
445
|
-
|
|
409
|
+
5. Creates the Super Admin scope (${SUPER_ADMIN_SCOPE_ID})
|
|
410
|
+
6. Assigns the user to the Super Admin scope with the super user role
|
|
411
|
+
(v5.x: Roles are assigned per-scope via hazo_user_scopes table)
|
|
446
412
|
|
|
447
413
|
Options:
|
|
448
414
|
--email=<email> Email address of the user to assign super user role
|
|
@@ -6,11 +6,12 @@ import type { HazoAuthUser } from "./auth_types";
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Cache entry structure
|
|
9
|
+
* v5.x: role_ids are now string UUIDs (from hazo_user_scopes)
|
|
9
10
|
*/
|
|
10
11
|
type CacheEntry = {
|
|
11
12
|
user: HazoAuthUser;
|
|
12
13
|
permissions: string[];
|
|
13
|
-
role_ids:
|
|
14
|
+
role_ids: string[];
|
|
14
15
|
timestamp: number; // Unix timestamp in milliseconds
|
|
15
16
|
cache_version: number; // Version number for smart invalidation
|
|
16
17
|
};
|
|
@@ -24,7 +25,7 @@ class AuthCache {
|
|
|
24
25
|
private max_size: number;
|
|
25
26
|
private ttl_ms: number;
|
|
26
27
|
private max_age_ms: number;
|
|
27
|
-
private role_version_map: Map<
|
|
28
|
+
private role_version_map: Map<string, number>; // Track version per role for smart invalidation (v5.x: string UUIDs)
|
|
28
29
|
|
|
29
30
|
constructor(
|
|
30
31
|
max_size: number,
|
|
@@ -81,13 +82,13 @@ class AuthCache {
|
|
|
81
82
|
* @param user_id - User ID
|
|
82
83
|
* @param user - User data
|
|
83
84
|
* @param permissions - User permissions
|
|
84
|
-
* @param role_ids - User role IDs
|
|
85
|
+
* @param role_ids - User role IDs (v5.x: string UUIDs)
|
|
85
86
|
*/
|
|
86
87
|
set(
|
|
87
88
|
user_id: string,
|
|
88
89
|
user: HazoAuthUser,
|
|
89
90
|
permissions: string[],
|
|
90
|
-
role_ids:
|
|
91
|
+
role_ids: string[],
|
|
91
92
|
): void {
|
|
92
93
|
// Evict LRU entries if cache is full
|
|
93
94
|
while (this.cache.size >= this.max_size) {
|
|
@@ -124,9 +125,9 @@ class AuthCache {
|
|
|
124
125
|
/**
|
|
125
126
|
* Invalidates cache for all users with specific roles
|
|
126
127
|
* Uses cache version to determine if invalidation is needed
|
|
127
|
-
* @param role_ids - Array of role IDs to invalidate
|
|
128
|
+
* @param role_ids - Array of role IDs to invalidate (v5.x: string UUIDs)
|
|
128
129
|
*/
|
|
129
|
-
invalidate_by_roles(role_ids:
|
|
130
|
+
invalidate_by_roles(role_ids: string[]): void {
|
|
130
131
|
// Increment version for affected roles
|
|
131
132
|
for (const role_id of role_ids) {
|
|
132
133
|
const current_version = this.role_version_map.get(role_id) || 0;
|
|
@@ -157,10 +158,10 @@ class AuthCache {
|
|
|
157
158
|
/**
|
|
158
159
|
* Gets the maximum cache version for a set of roles
|
|
159
160
|
* Used to determine if cache entry is stale
|
|
160
|
-
* @param role_ids - Array of role IDs
|
|
161
|
+
* @param role_ids - Array of role IDs (v5.x: string UUIDs)
|
|
161
162
|
* @returns Maximum version number
|
|
162
163
|
*/
|
|
163
|
-
private get_max_role_version(role_ids:
|
|
164
|
+
private get_max_role_version(role_ids: string[]): number {
|
|
164
165
|
if (role_ids.length === 0) {
|
|
165
166
|
return 0;
|
|
166
167
|
}
|
|
@@ -77,14 +77,29 @@ function get_client_ip(request: NextRequest): string {
|
|
|
77
77
|
* @param user_id - User ID
|
|
78
78
|
* @returns Object with user, permissions, and role_ids
|
|
79
79
|
*/
|
|
80
|
+
/**
|
|
81
|
+
* CRUD service options for hazo_user_scopes table
|
|
82
|
+
* This table uses a composite primary key (user_id, scope_id) and no 'id' column
|
|
83
|
+
*/
|
|
84
|
+
const USER_SCOPES_CRUD_OPTIONS = {
|
|
85
|
+
primaryKeys: ["user_id", "scope_id"],
|
|
86
|
+
autoId: false as const,
|
|
87
|
+
};
|
|
88
|
+
|
|
80
89
|
async function fetch_user_data_from_db(user_id: string): Promise<{
|
|
81
90
|
user: HazoAuthUser;
|
|
82
91
|
permissions: string[];
|
|
83
|
-
role_ids:
|
|
92
|
+
role_ids: string[];
|
|
84
93
|
}> {
|
|
85
94
|
const hazoConnect = get_hazo_connect_instance();
|
|
86
95
|
const users_service = createCrudService(hazoConnect, "hazo_users");
|
|
87
|
-
|
|
96
|
+
// v5.x: Use hazo_user_scopes instead of hazo_user_roles
|
|
97
|
+
// Roles are now assigned per-scope via hazo_user_scopes.role_id
|
|
98
|
+
const user_scopes_service = createCrudService(
|
|
99
|
+
hazoConnect,
|
|
100
|
+
"hazo_user_scopes",
|
|
101
|
+
USER_SCOPES_CRUD_OPTIONS,
|
|
102
|
+
);
|
|
88
103
|
const role_permissions_service = createCrudService(
|
|
89
104
|
hazoConnect,
|
|
90
105
|
"hazo_role_permissions",
|
|
@@ -118,34 +133,36 @@ async function fetch_user_data_from_db(user_id: string): Promise<{
|
|
|
118
133
|
app_user_data: parse_app_user_data(user_db.app_user_data),
|
|
119
134
|
};
|
|
120
135
|
|
|
121
|
-
// Fetch user roles
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
136
|
+
// v5.x: Fetch user's roles from hazo_user_scopes (scope-based role assignments)
|
|
137
|
+
// Each scope assignment has a role_id (string UUID)
|
|
138
|
+
const user_scopes = await user_scopes_service.findBy({ user_id });
|
|
139
|
+
const role_ids_set = new Set<string>();
|
|
140
|
+
if (Array.isArray(user_scopes)) {
|
|
141
|
+
for (const us of user_scopes) {
|
|
142
|
+
const role_id = us.role_id as string | undefined;
|
|
143
|
+
if (role_id) {
|
|
144
|
+
role_ids_set.add(role_id);
|
|
129
145
|
}
|
|
130
146
|
}
|
|
131
147
|
}
|
|
148
|
+
const role_ids = Array.from(role_ids_set);
|
|
132
149
|
|
|
133
150
|
// Fetch role permissions
|
|
134
151
|
const permissions_set = new Set<string>();
|
|
135
152
|
if (role_ids.length > 0) {
|
|
136
153
|
const role_permissions = await role_permissions_service.findBy({});
|
|
137
154
|
if (Array.isArray(role_permissions)) {
|
|
138
|
-
// Filter role_permissions for user's roles
|
|
155
|
+
// Filter role_permissions for user's roles (role_id is string UUID in v5.x)
|
|
139
156
|
const user_role_permissions = role_permissions.filter((rp) =>
|
|
140
|
-
role_ids.includes(rp.role_id as
|
|
157
|
+
role_ids.includes(rp.role_id as string),
|
|
141
158
|
);
|
|
142
159
|
|
|
143
|
-
// Get permission IDs
|
|
144
|
-
const permission_ids = new Set<
|
|
160
|
+
// Get permission IDs (can be string or number depending on database)
|
|
161
|
+
const permission_ids = new Set<string>();
|
|
145
162
|
for (const rp of user_role_permissions) {
|
|
146
|
-
const perm_id = rp.permission_id as number | undefined;
|
|
163
|
+
const perm_id = rp.permission_id as string | number | undefined;
|
|
147
164
|
if (perm_id !== undefined) {
|
|
148
|
-
permission_ids.add(perm_id);
|
|
165
|
+
permission_ids.add(String(perm_id));
|
|
149
166
|
}
|
|
150
167
|
}
|
|
151
168
|
|
|
@@ -154,8 +171,8 @@ async function fetch_user_data_from_db(user_id: string): Promise<{
|
|
|
154
171
|
const permissions = await permissions_service.findBy({});
|
|
155
172
|
if (Array.isArray(permissions)) {
|
|
156
173
|
for (const perm of permissions) {
|
|
157
|
-
const perm_id = perm.id as number | undefined;
|
|
158
|
-
if (perm_id !== undefined && permission_ids.has(perm_id)) {
|
|
174
|
+
const perm_id = perm.id as string | number | undefined;
|
|
175
|
+
if (perm_id !== undefined && permission_ids.has(String(perm_id))) {
|
|
159
176
|
const perm_name = perm.permission_name as string | undefined;
|
|
160
177
|
if (perm_name) {
|
|
161
178
|
permissions_set.add(perm_name);
|
|
@@ -398,7 +415,7 @@ export async function hazo_get_auth(
|
|
|
398
415
|
let cached_entry = cache.get(user_id);
|
|
399
416
|
let user: HazoAuthUser;
|
|
400
417
|
let permissions: string[];
|
|
401
|
-
let role_ids:
|
|
418
|
+
let role_ids: string[]; // v5.x: role_ids are now string UUIDs
|
|
402
419
|
|
|
403
420
|
if (cached_entry) {
|
|
404
421
|
// Cache hit
|
package/cli-src/lib/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// file_description: barrel export for lib utilities
|
|
2
2
|
// section: auth_exports
|
|
3
|
-
export * from "./auth/index";
|
|
3
|
+
export * from "./auth/index.js";
|
|
4
4
|
|
|
5
5
|
// section: service_exports
|
|
6
|
-
export * from "./services/index";
|
|
6
|
+
export * from "./services/index.js";
|
|
7
7
|
|
|
8
8
|
// section: utility_exports
|
|
9
9
|
export { cn, merge_class_names } from "./utils.js";
|
|
@@ -44,5 +44,5 @@ export type { FirmBrandingConfig } from "./branding_config.server";
|
|
|
44
44
|
// section: util_exports
|
|
45
45
|
export { sanitize_error_for_user } from "./utils/error_sanitizer.js";
|
|
46
46
|
export type { ErrorSanitizationOptions } from "./utils/error_sanitizer";
|
|
47
|
-
export * from "./utils/api_route_helpers";
|
|
47
|
+
export * from "./utils/api_route_helpers.js";
|
|
48
48
|
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
// file_description: barrel export for all services
|
|
2
2
|
// section: service_exports
|
|
3
|
-
export * from "./email_service";
|
|
4
|
-
export * from "./email_verification_service";
|
|
5
|
-
export * from "./login_service";
|
|
6
|
-
export * from "./password_change_service";
|
|
7
|
-
export * from "./password_reset_service";
|
|
8
|
-
export * from "./profile_picture_remove_service";
|
|
9
|
-
export * from "./profile_picture_service";
|
|
10
|
-
export * from "./profile_picture_source_mapper";
|
|
11
|
-
export * from "./registration_service";
|
|
12
|
-
export * from "./token_service";
|
|
13
|
-
export * from "./user_profiles_service";
|
|
14
|
-
export * from "./user_update_service";
|
|
15
|
-
export * from "./app_user_data_service";
|
|
16
|
-
export * from "./invitation_service";
|
|
17
|
-
export * from "./firm_service";
|
|
18
|
-
export * from "./post_verification_service";
|
|
19
|
-
export * from "./scope_service";
|
|
20
|
-
export * from "./user_scope_service";
|
|
21
|
-
export * from "./oauth_service";
|
|
22
|
-
export * from "./branding_service";
|
|
3
|
+
export * from "./email_service.js";
|
|
4
|
+
export * from "./email_verification_service.js";
|
|
5
|
+
export * from "./login_service.js";
|
|
6
|
+
export * from "./password_change_service.js";
|
|
7
|
+
export * from "./password_reset_service.js";
|
|
8
|
+
export * from "./profile_picture_remove_service.js";
|
|
9
|
+
export * from "./profile_picture_service.js";
|
|
10
|
+
export * from "./profile_picture_source_mapper.js";
|
|
11
|
+
export * from "./registration_service.js";
|
|
12
|
+
export * from "./token_service.js";
|
|
13
|
+
export * from "./user_profiles_service.js";
|
|
14
|
+
export * from "./user_update_service.js";
|
|
15
|
+
export * from "./app_user_data_service.js";
|
|
16
|
+
export * from "./invitation_service.js";
|
|
17
|
+
export * from "./firm_service.js";
|
|
18
|
+
export * from "./post_verification_service.js";
|
|
19
|
+
export * from "./scope_service.js";
|
|
20
|
+
export * from "./user_scope_service.js";
|
|
21
|
+
export * from "./oauth_service.js";
|
|
22
|
+
export * from "./branding_service.js";
|
|
23
23
|
|
|
24
24
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init_users.d.ts","sourceRoot":"","sources":["../../src/cli/init_users.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init_users.d.ts","sourceRoot":"","sources":["../../src/cli/init_users.ts"],"names":[],"mappings":"AAuGA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmRrF;AAGD;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAkC3C"}
|
package/dist/cli/init_users.js
CHANGED
|
@@ -44,15 +44,7 @@ function print_summary(summary) {
|
|
|
44
44
|
console.log(` ⊙ Already existed: ${summary.role_permissions.existing} assignment(s)`);
|
|
45
45
|
}
|
|
46
46
|
console.log();
|
|
47
|
-
// User
|
|
48
|
-
console.log("User-Role Assignment:");
|
|
49
|
-
if (summary.user_role.inserted) {
|
|
50
|
-
console.log(` ✓ Inserted: Super user role assigned to user`);
|
|
51
|
-
}
|
|
52
|
-
if (summary.user_role.existing) {
|
|
53
|
-
console.log(` ⊙ Already existed: User already has super user role`);
|
|
54
|
-
}
|
|
55
|
-
console.log();
|
|
47
|
+
// v5.x: User-Role assignments are now handled via User-Scope assignments (see below)
|
|
56
48
|
// Super admin scope summary
|
|
57
49
|
console.log("Super Admin Scope:");
|
|
58
50
|
if (summary.super_admin_scope.inserted) {
|
|
@@ -98,10 +90,7 @@ export async function handle_init_users(options = {}) {
|
|
|
98
90
|
inserted: 0,
|
|
99
91
|
existing: 0,
|
|
100
92
|
},
|
|
101
|
-
|
|
102
|
-
inserted: false,
|
|
103
|
-
existing: false,
|
|
104
|
-
},
|
|
93
|
+
// v5.x: Removed user_role - roles are now assigned via hazo_user_scopes
|
|
105
94
|
super_admin_scope: {
|
|
106
95
|
inserted: false,
|
|
107
96
|
existing: false,
|
|
@@ -120,7 +109,7 @@ export async function handle_init_users(options = {}) {
|
|
|
120
109
|
const roles_service = createCrudService(hazoConnect, "hazo_roles");
|
|
121
110
|
const role_permissions_service = createCrudService(hazoConnect, "hazo_role_permissions");
|
|
122
111
|
const users_service = createCrudService(hazoConnect, "hazo_users");
|
|
123
|
-
|
|
112
|
+
// v5.x: Removed hazo_user_roles - roles are now assigned via hazo_user_scopes
|
|
124
113
|
const scopes_service = createCrudService(hazoConnect, "hazo_scopes");
|
|
125
114
|
// hazo_user_scopes uses composite primary key (user_id, scope_id), no 'id' column
|
|
126
115
|
const user_scopes_service = createCrudService(hazoConnect, "hazo_user_scopes", {
|
|
@@ -255,26 +244,7 @@ export async function handle_init_users(options = {}) {
|
|
|
255
244
|
const user_id = user.id;
|
|
256
245
|
console.log(`✓ Found user: ${super_user_email} (ID: ${user_id})`);
|
|
257
246
|
console.log();
|
|
258
|
-
//
|
|
259
|
-
const existing_user_roles = await user_roles_service.findBy({
|
|
260
|
-
user_id,
|
|
261
|
-
role_id,
|
|
262
|
-
});
|
|
263
|
-
if (Array.isArray(existing_user_roles) && existing_user_roles.length > 0) {
|
|
264
|
-
summary.user_role.existing = true;
|
|
265
|
-
console.log(`✓ User already has role assigned: ${user_id} -> ${role_name}`);
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
await user_roles_service.insert({
|
|
269
|
-
user_id,
|
|
270
|
-
role_id,
|
|
271
|
-
created_at: now,
|
|
272
|
-
changed_at: now,
|
|
273
|
-
});
|
|
274
|
-
summary.user_role.inserted = true;
|
|
275
|
-
console.log(`✓ Assigned role to user: ${user_id} -> ${role_name}`);
|
|
276
|
-
}
|
|
277
|
-
console.log();
|
|
247
|
+
// v5.x: Step 7 removed - role assignment now happens via hazo_user_scopes (see step 9)
|
|
278
248
|
// 8. Ensure super admin scope exists
|
|
279
249
|
const existing_scopes = await scopes_service.findBy({ id: SUPER_ADMIN_SCOPE_ID });
|
|
280
250
|
if (Array.isArray(existing_scopes) && existing_scopes.length > 0) {
|
|
@@ -357,9 +327,9 @@ This command reads from hazo_auth_config.ini and:
|
|
|
357
327
|
2. Creates a 'default_super_user_role' role
|
|
358
328
|
3. Assigns all permissions to the super user role
|
|
359
329
|
4. Finds user by email (from --email parameter or config)
|
|
360
|
-
5.
|
|
361
|
-
6.
|
|
362
|
-
|
|
330
|
+
5. Creates the Super Admin scope (${SUPER_ADMIN_SCOPE_ID})
|
|
331
|
+
6. Assigns the user to the Super Admin scope with the super user role
|
|
332
|
+
(v5.x: Roles are assigned per-scope via hazo_user_scopes table)
|
|
363
333
|
|
|
364
334
|
Options:
|
|
365
335
|
--email=<email> Email address of the user to assign super user role
|
package/dist/client.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from "./components/index";
|
|
2
|
-
export { cn, merge_class_names } from "./lib/utils";
|
|
3
|
-
export * from "./lib/auth/auth_types";
|
|
4
|
-
export { use_auth_status, trigger_auth_status_refresh } from "./components/layouts/shared/hooks/use_auth_status";
|
|
5
|
-
export { use_hazo_auth, trigger_hazo_auth_refresh } from "./components/layouts/shared/hooks/use_hazo_auth";
|
|
1
|
+
export * from "./components/index.js";
|
|
2
|
+
export { cn, merge_class_names } from "./lib/utils.js";
|
|
3
|
+
export * from "./lib/auth/auth_types.js";
|
|
4
|
+
export { use_auth_status, trigger_auth_status_refresh } from "./components/layouts/shared/hooks/use_auth_status.js";
|
|
5
|
+
export { use_hazo_auth, trigger_hazo_auth_refresh } from "./components/layouts/shared/hooks/use_hazo_auth.js";
|
|
6
6
|
export type { UseHazoAuthOptions, UseHazoAuthResult } from "./components/layouts/shared/hooks/use_hazo_auth";
|
|
7
|
-
export { use_firm_branding, use_current_user_branding } from "./components/layouts/shared/hooks/use_firm_branding";
|
|
7
|
+
export { use_firm_branding, use_current_user_branding } from "./components/layouts/shared/hooks/use_firm_branding.js";
|
|
8
8
|
export type { FirmBranding, UseFirmBrandingOptions, UseFirmBrandingResult } from "./components/layouts/shared/hooks/use_firm_branding";
|
|
9
|
-
export * from "./components/layouts/shared/utils/validation";
|
|
9
|
+
export * from "./components/layouts/shared/utils/validation.js";
|
|
10
10
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.js
CHANGED
|
@@ -9,18 +9,18 @@
|
|
|
9
9
|
// import { hazo_get_auth, get_config_value } from "hazo_auth";
|
|
10
10
|
// section: component_exports
|
|
11
11
|
// All UI and layout components are client-safe
|
|
12
|
-
export * from "./components/index";
|
|
12
|
+
export * from "./components/index.js";
|
|
13
13
|
// section: utility_exports
|
|
14
14
|
// CSS utility functions
|
|
15
|
-
export { cn, merge_class_names } from "./lib/utils";
|
|
15
|
+
export { cn, merge_class_names } from "./lib/utils.js";
|
|
16
16
|
// section: type_exports
|
|
17
17
|
// Type definitions are always safe (erased at runtime)
|
|
18
|
-
export * from "./lib/auth/auth_types";
|
|
18
|
+
export * from "./lib/auth/auth_types.js";
|
|
19
19
|
// section: client_hook_exports
|
|
20
20
|
// Re-export from shared hooks (these are already "use client" components)
|
|
21
|
-
export { use_auth_status, trigger_auth_status_refresh } from "./components/layouts/shared/hooks/use_auth_status";
|
|
22
|
-
export { use_hazo_auth, trigger_hazo_auth_refresh } from "./components/layouts/shared/hooks/use_hazo_auth";
|
|
23
|
-
export { use_firm_branding, use_current_user_branding } from "./components/layouts/shared/hooks/use_firm_branding";
|
|
21
|
+
export { use_auth_status, trigger_auth_status_refresh } from "./components/layouts/shared/hooks/use_auth_status.js";
|
|
22
|
+
export { use_hazo_auth, trigger_hazo_auth_refresh } from "./components/layouts/shared/hooks/use_hazo_auth.js";
|
|
23
|
+
export { use_firm_branding, use_current_user_branding } from "./components/layouts/shared/hooks/use_firm_branding.js";
|
|
24
24
|
// section: validation_exports
|
|
25
25
|
// Client-side validation utilities
|
|
26
|
-
export * from "./components/layouts/shared/utils/validation";
|
|
26
|
+
export * from "./components/layouts/shared/utils/validation.js";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./ui/index";
|
|
2
|
-
export * from "./layouts/index";
|
|
1
|
+
export * from "./ui/index.js";
|
|
2
|
+
export * from "./layouts/index.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/components/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StaticImageData } from "next/image";
|
|
2
|
-
import { type ButtonPaletteOverrides } from "../shared/config/layout_customization";
|
|
2
|
+
import { type ButtonPaletteOverrides } from "../shared/config/layout_customization.js";
|
|
3
3
|
export type CreateFirmLayoutProps = {
|
|
4
4
|
/** Image source for the left panel */
|
|
5
5
|
image_src: string | StaticImageData;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// section: client_directive
|
|
3
3
|
"use client";
|
|
4
4
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { Input } from "../../ui/input";
|
|
6
|
-
import { FormFieldWrapper } from "../shared/components/form_field_wrapper";
|
|
7
|
-
import { FormHeader } from "../shared/components/form_header";
|
|
8
|
-
import { FormActionButtons } from "../shared/components/form_action_buttons";
|
|
9
|
-
import { TwoColumnAuthLayout } from "../shared/components/two_column_auth_layout";
|
|
5
|
+
import { Input } from "../../ui/input.js";
|
|
6
|
+
import { FormFieldWrapper } from "../shared/components/form_field_wrapper.js";
|
|
7
|
+
import { FormHeader } from "../shared/components/form_header.js";
|
|
8
|
+
import { FormActionButtons } from "../shared/components/form_action_buttons.js";
|
|
9
|
+
import { TwoColumnAuthLayout } from "../shared/components/two_column_auth_layout.js";
|
|
10
10
|
import { CheckCircle, Building2 } from "lucide-react";
|
|
11
|
-
import { use_create_firm_form, } from "./hooks/use_create_firm_form";
|
|
12
|
-
import { useHazoAuthConfig } from "../../../contexts/hazo_auth_provider";
|
|
11
|
+
import { use_create_firm_form, } from "./hooks/use_create_firm_form.js";
|
|
12
|
+
import { useHazoAuthConfig } from "../../../contexts/hazo_auth_provider.js";
|
|
13
13
|
// section: component
|
|
14
14
|
export default function CreateFirmLayout({ image_src, image_alt = "Create your firm", image_background_color = "#f1f5f9", heading = "Create Your Firm", sub_heading = "Set up your organisation to get started", firm_name_label = "Firm Name", firm_name_placeholder = "Enter your firm name", org_structure_label = "Organisation Structure", org_structure_placeholder = "e.g., Headquarters, Head Office", default_org_structure = "Headquarters", submit_button_label = "Create Firm", success_message = "Your firm has been created successfully!", redirect_route = "/", apiBasePath, onSuccess, button_colors, logger, }) {
|
|
15
15
|
const { apiBasePath: contextApiBasePath } = useHazoAuthConfig();
|
|
@@ -6,8 +6,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
6
6
|
// section: imports
|
|
7
7
|
import { useState, useCallback } from "react";
|
|
8
8
|
import Image from "next/image";
|
|
9
|
-
import { Input } from "../../ui/input";
|
|
10
|
-
import { Button } from "../../ui/button";
|
|
9
|
+
import { Input } from "../../ui/input.js";
|
|
10
|
+
import { Button } from "../../ui/button.js";
|
|
11
11
|
import { Lock, AlertCircle, Loader2 } from "lucide-react";
|
|
12
12
|
// section: component
|
|
13
13
|
export default function DevLockLayout({ background_color = "#000000", logo_path = "", logo_width = 120, logo_height = 120, application_name = "", limited_access_text = "Limited Access", password_placeholder = "Enter access password", submit_button_text = "Unlock", error_message = "Incorrect password", text_color = "#ffffff", accent_color = "#3b82f6", onUnlock, }) {
|
package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LayoutFieldMap, LayoutFieldMapOverrides } from "../../shared/config/layout_customization";
|
|
2
|
-
import { type ButtonPaletteDefaults, type ButtonPaletteOverrides, type LayoutLabelDefaults, type LayoutLabelOverrides } from "../../shared/config/layout_customization";
|
|
2
|
+
import { type ButtonPaletteDefaults, type ButtonPaletteOverrides, type LayoutLabelDefaults, type LayoutLabelOverrides } from "../../shared/config/layout_customization.js";
|
|
3
3
|
export declare const EMAIL_VERIFICATION_FIELD_IDS: {
|
|
4
4
|
readonly EMAIL: "email_address";
|
|
5
5
|
};
|
package/dist/components/layouts/email_verification/config/email_verification_field_config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveButtonPalette, resolveFieldDefinitions, resolveLabels, } from "../../shared/config/layout_customization";
|
|
1
|
+
import { resolveButtonPalette, resolveFieldDefinitions, resolveLabels, } from "../../shared/config/layout_customization.js";
|
|
2
2
|
// section: field_identifiers
|
|
3
3
|
export const EMAIL_VERIFICATION_FIELD_IDS = {
|
|
4
4
|
EMAIL: "email_address",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LayoutDataClient } from "../../shared/data/layout_data_client";
|
|
2
|
-
import { type EmailVerificationFieldId } from "../config/email_verification_field_config";
|
|
2
|
+
import { type EmailVerificationFieldId } from "../config/email_verification_field_config.js";
|
|
3
3
|
export type EmailVerificationFormValues = Record<EmailVerificationFieldId, string>;
|
|
4
4
|
export type EmailVerificationFormErrors = Partial<Record<EmailVerificationFieldId, string>> & {
|
|
5
5
|
submit?: string;
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
4
4
|
import { useRouter, useSearchParams } from "next/navigation";
|
|
5
5
|
import { toast } from "sonner";
|
|
6
|
-
import { EMAIL_VERIFICATION_FIELD_IDS } from "../config/email_verification_field_config";
|
|
7
|
-
import { validateEmail } from "../../shared/utils/validation";
|
|
8
|
-
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider";
|
|
6
|
+
import { EMAIL_VERIFICATION_FIELD_IDS } from "../config/email_verification_field_config.js";
|
|
7
|
+
import { validateEmail } from "../../shared/utils/validation.js";
|
|
8
|
+
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider.js";
|
|
9
9
|
// section: helpers
|
|
10
10
|
const buildInitialValues = (initialEmail) => ({
|
|
11
11
|
[EMAIL_VERIFICATION_FIELD_IDS.EMAIL]: initialEmail || "",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StaticImageData } from "next/image";
|
|
2
|
-
import { type ButtonPaletteOverrides, type LayoutFieldMapOverrides, type LayoutLabelOverrides } from "../shared/config/layout_customization";
|
|
3
|
-
import { type EmailVerificationSuccessLabels, type EmailVerificationErrorLabels } from "./config/email_verification_field_config";
|
|
4
|
-
import { type LayoutDataClient } from "../shared/data/layout_data_client";
|
|
2
|
+
import { type ButtonPaletteOverrides, type LayoutFieldMapOverrides, type LayoutLabelOverrides } from "../shared/config/layout_customization.js";
|
|
3
|
+
import { type EmailVerificationSuccessLabels, type EmailVerificationErrorLabels } from "./config/email_verification_field_config.js";
|
|
4
|
+
import { type LayoutDataClient } from "../shared/data/layout_data_client.js";
|
|
5
5
|
export type EmailVerificationLayoutProps<TClient = unknown> = {
|
|
6
6
|
image_src: string | StaticImageData;
|
|
7
7
|
image_alt: string;
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
"use client";
|
|
4
4
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
5
5
|
// section: imports
|
|
6
|
-
import { Input } from "../../ui/input";
|
|
7
|
-
import { Button } from "../../ui/button";
|
|
8
|
-
import { FormFieldWrapper } from "../shared/components/form_field_wrapper";
|
|
9
|
-
import { FormHeader } from "../shared/components/form_header";
|
|
10
|
-
import { FormActionButtons } from "../shared/components/form_action_buttons";
|
|
11
|
-
import { TwoColumnAuthLayout } from "../shared/components/two_column_auth_layout";
|
|
12
|
-
import { EMAIL_VERIFICATION_FIELD_IDS, createEmailVerificationFieldDefinitions, resolveEmailVerificationButtonPalette, resolveEmailVerificationLabels, EMAIL_VERIFICATION_SUCCESS_LABEL_DEFAULTS, EMAIL_VERIFICATION_ERROR_LABEL_DEFAULTS, } from "./config/email_verification_field_config";
|
|
13
|
-
import { use_email_verification, } from "./hooks/use_email_verification";
|
|
6
|
+
import { Input } from "../../ui/input.js";
|
|
7
|
+
import { Button } from "../../ui/button.js";
|
|
8
|
+
import { FormFieldWrapper } from "../shared/components/form_field_wrapper.js";
|
|
9
|
+
import { FormHeader } from "../shared/components/form_header.js";
|
|
10
|
+
import { FormActionButtons } from "../shared/components/form_action_buttons.js";
|
|
11
|
+
import { TwoColumnAuthLayout } from "../shared/components/two_column_auth_layout.js";
|
|
12
|
+
import { EMAIL_VERIFICATION_FIELD_IDS, createEmailVerificationFieldDefinitions, resolveEmailVerificationButtonPalette, resolveEmailVerificationLabels, EMAIL_VERIFICATION_SUCCESS_LABEL_DEFAULTS, EMAIL_VERIFICATION_ERROR_LABEL_DEFAULTS, } from "./config/email_verification_field_config.js";
|
|
13
|
+
import { use_email_verification, } from "./hooks/use_email_verification.js";
|
|
14
14
|
import { CheckCircle, XCircle, Loader2 } from "lucide-react";
|
|
15
|
-
import { AlreadyLoggedInGuard } from "../shared/components/already_logged_in_guard";
|
|
15
|
+
import { AlreadyLoggedInGuard } from "../shared/components/already_logged_in_guard.js";
|
|
16
16
|
import Link from "next/link";
|
|
17
17
|
const ORDERED_FIELDS = [
|
|
18
18
|
EMAIL_VERIFICATION_FIELD_IDS.EMAIL,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LayoutFieldMap, LayoutFieldMapOverrides } from "../../shared/config/layout_customization";
|
|
2
|
-
import { type ButtonPaletteDefaults, type ButtonPaletteOverrides, type LayoutLabelDefaults, type LayoutLabelOverrides } from "../../shared/config/layout_customization";
|
|
2
|
+
import { type ButtonPaletteDefaults, type ButtonPaletteOverrides, type LayoutLabelDefaults, type LayoutLabelOverrides } from "../../shared/config/layout_customization.js";
|
|
3
3
|
export declare const FORGOT_PASSWORD_FIELD_IDS: {
|
|
4
4
|
readonly EMAIL: "email_address";
|
|
5
5
|
};
|