hazo_auth 1.2.0 → 1.4.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 +383 -774
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +5 -0
- package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts +23 -0
- package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts.map +1 -0
- package/dist/components/layouts/email_verification/config/email_verification_field_config.js +44 -0
- package/dist/components/layouts/email_verification/hooks/use_email_verification.d.ts +31 -0
- package/dist/components/layouts/email_verification/hooks/use_email_verification.d.ts.map +1 -0
- package/dist/components/layouts/email_verification/hooks/use_email_verification.js +222 -0
- package/dist/components/layouts/email_verification/index.d.ts +23 -0
- package/dist/components/layouts/email_verification/index.d.ts.map +1 -0
- package/dist/components/layouts/email_verification/index.js +61 -0
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts +10 -0
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts.map +1 -0
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.js +33 -0
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts +22 -0
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts.map +1 -0
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.js +127 -0
- package/dist/components/layouts/forgot_password/index.d.ts +18 -0
- package/dist/components/layouts/forgot_password/index.d.ts.map +1 -0
- package/dist/components/layouts/forgot_password/index.js +43 -0
- package/dist/components/layouts/index.d.ts +16 -0
- package/dist/components/layouts/index.d.ts.map +1 -0
- package/dist/components/layouts/index.js +11 -0
- package/dist/components/layouts/login/config/login_field_config.d.ts +11 -0
- package/dist/components/layouts/login/config/login_field_config.d.ts.map +1 -0
- package/dist/components/layouts/login/config/login_field_config.js +42 -0
- package/dist/components/layouts/login/hooks/use_login_form.d.ts +34 -0
- package/dist/components/layouts/login/hooks/use_login_form.d.ts.map +1 -0
- package/dist/components/layouts/login/hooks/use_login_form.js +196 -0
- package/dist/components/layouts/login/index.d.ts +31 -0
- package/dist/components/layouts/login/index.d.ts.map +1 -0
- package/dist/components/layouts/login/index.js +58 -0
- package/dist/components/layouts/my_settings/components/editable_field.d.ts +19 -0
- package/dist/components/layouts/my_settings/components/editable_field.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/editable_field.js +73 -0
- package/dist/components/layouts/my_settings/components/password_change_dialog.d.ts +28 -0
- package/dist/components/layouts/my_settings/components/password_change_dialog.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/password_change_dialog.js +138 -0
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.d.ts +42 -0
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.js +198 -0
- package/dist/components/layouts/my_settings/components/profile_picture_display.d.ts +16 -0
- package/dist/components/layouts/my_settings/components/profile_picture_display.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/profile_picture_display.js +33 -0
- package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.d.ts +17 -0
- package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.js +48 -0
- package/dist/components/layouts/my_settings/components/profile_picture_library_tab.d.ts +21 -0
- package/dist/components/layouts/my_settings/components/profile_picture_library_tab.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/profile_picture_library_tab.js +144 -0
- package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.d.ts +23 -0
- package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.js +169 -0
- package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts +19 -0
- package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/config/my_settings_field_config.js +26 -0
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts +46 -0
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/hooks/use_my_settings.js +354 -0
- package/dist/components/layouts/my_settings/index.d.ts +64 -0
- package/dist/components/layouts/my_settings/index.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/index.js +65 -0
- package/dist/components/layouts/register/config/register_field_config.d.ts +14 -0
- package/dist/components/layouts/register/config/register_field_config.d.ts.map +1 -0
- package/dist/components/layouts/register/config/register_field_config.js +69 -0
- package/dist/components/layouts/register/hooks/use_register_form.d.ts +30 -0
- package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -0
- package/dist/components/layouts/register/hooks/use_register_form.js +184 -0
- package/dist/components/layouts/register/index.d.ts +23 -0
- package/dist/components/layouts/register/index.d.ts.map +1 -0
- package/dist/components/layouts/register/index.js +58 -0
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts +13 -0
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts.map +1 -0
- package/dist/components/layouts/reset_password/config/reset_password_field_config.js +53 -0
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.d.ts +28 -0
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.d.ts.map +1 -0
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.js +201 -0
- package/dist/components/layouts/reset_password/index.d.ts +23 -0
- package/dist/components/layouts/reset_password/index.d.ts.map +1 -0
- package/dist/components/layouts/reset_password/index.js +53 -0
- package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts +20 -0
- package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/already_logged_in_guard.js +32 -0
- package/dist/components/layouts/shared/components/auth_page_shell.d.ts +7 -0
- package/dist/components/layouts/shared/components/auth_page_shell.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/auth_page_shell.js +12 -0
- package/dist/components/layouts/shared/components/field_error_message.d.ts +7 -0
- package/dist/components/layouts/shared/components/field_error_message.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/field_error_message.js +6 -0
- package/dist/components/layouts/shared/components/form_action_buttons.d.ts +14 -0
- package/dist/components/layouts/shared/components/form_action_buttons.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/form_action_buttons.js +15 -0
- package/dist/components/layouts/shared/components/form_field_wrapper.d.ts +11 -0
- package/dist/components/layouts/shared/components/form_field_wrapper.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/form_field_wrapper.js +9 -0
- package/dist/components/layouts/shared/components/form_header.d.ts +10 -0
- package/dist/components/layouts/shared/components/form_header.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/form_header.js +5 -0
- package/dist/components/layouts/shared/components/logout_button.d.ts +7 -0
- package/dist/components/layouts/shared/components/logout_button.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/logout_button.js +44 -0
- package/dist/components/layouts/shared/components/password_field.d.ts +13 -0
- package/dist/components/layouts/shared/components/password_field.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/password_field.js +13 -0
- package/dist/components/layouts/shared/components/profile_pic_menu.d.ts +22 -0
- package/dist/components/layouts/shared/components/profile_pic_menu.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/profile_pic_menu.js +169 -0
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.d.ts +12 -0
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.js +16 -0
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.d.ts +6 -0
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.js +15 -0
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.d.ts +11 -0
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.js +10 -0
- package/dist/components/layouts/shared/components/two_column_auth_layout.d.ts +12 -0
- package/dist/components/layouts/shared/components/two_column_auth_layout.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/two_column_auth_layout.js +8 -0
- package/dist/components/layouts/shared/components/unauthorized_guard.d.ts +14 -0
- package/dist/components/layouts/shared/components/unauthorized_guard.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/unauthorized_guard.js +30 -0
- package/dist/components/layouts/shared/components/visual_panel.d.ts +9 -0
- package/dist/components/layouts/shared/components/visual_panel.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/visual_panel.js +10 -0
- package/dist/components/layouts/shared/config/layout_customization.d.ts +38 -0
- package/dist/components/layouts/shared/config/layout_customization.d.ts.map +1 -0
- package/dist/components/layouts/shared/config/layout_customization.js +19 -0
- package/dist/components/layouts/shared/data/layout_data_client.d.ts +6 -0
- package/dist/components/layouts/shared/data/layout_data_client.d.ts.map +1 -0
- package/dist/components/layouts/shared/data/layout_data_client.js +9 -0
- package/dist/components/layouts/shared/hooks/use_auth_status.d.ts +20 -0
- package/dist/components/layouts/shared/hooks/use_auth_status.d.ts.map +1 -0
- package/dist/components/layouts/shared/hooks/use_auth_status.js +71 -0
- package/dist/components/layouts/shared/hooks/use_hazo_auth.d.ts +48 -0
- package/dist/components/layouts/shared/hooks/use_hazo_auth.d.ts.map +1 -0
- package/dist/components/layouts/shared/hooks/use_hazo_auth.js +90 -0
- package/dist/components/layouts/shared/index.d.ts +24 -0
- package/dist/components/layouts/shared/index.d.ts.map +1 -0
- package/dist/components/layouts/shared/index.js +27 -0
- package/dist/components/layouts/shared/utils/ip_address.d.ts +7 -0
- package/dist/components/layouts/shared/utils/ip_address.d.ts.map +1 -0
- package/dist/components/layouts/shared/utils/ip_address.js +34 -0
- package/dist/components/layouts/shared/utils/validation.d.ts +15 -0
- package/dist/components/layouts/shared/utils/validation.d.ts.map +1 -0
- package/dist/components/layouts/shared/utils/validation.js +45 -0
- package/dist/components/layouts/user_management/components/roles_matrix.d.ts +29 -0
- package/dist/components/layouts/user_management/components/roles_matrix.d.ts.map +1 -0
- package/dist/components/layouts/user_management/components/roles_matrix.js +287 -0
- package/dist/components/layouts/user_management/index.d.ts +13 -0
- package/dist/components/layouts/user_management/index.d.ts.map +1 -0
- package/dist/components/layouts/user_management/index.js +495 -0
- package/dist/components/ui/alert-dialog.d.ts +21 -0
- package/dist/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/components/ui/alert-dialog.js +62 -0
- package/dist/components/ui/avatar.d.ts +7 -0
- package/dist/components/ui/avatar.d.ts.map +1 -0
- package/dist/components/ui/avatar.js +32 -0
- package/dist/components/ui/button.d.ts +12 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +45 -0
- package/dist/components/ui/checkbox.d.ts +5 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/checkbox.js +23 -0
- package/dist/components/ui/dialog.d.ts +20 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dialog.js +52 -0
- package/dist/components/ui/dropdown-menu.d.ts +28 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.js +72 -0
- package/dist/components/ui/hazo_ui_tooltip.d.ts +26 -0
- package/dist/components/ui/hazo_ui_tooltip.d.ts.map +1 -0
- package/dist/components/ui/hazo_ui_tooltip.js +17 -0
- package/dist/components/ui/index.d.ts +20 -0
- package/dist/components/ui/index.d.ts.map +1 -0
- package/dist/components/ui/index.js +21 -0
- package/dist/components/ui/input.d.ts +4 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +20 -0
- package/dist/components/ui/label.d.ts +6 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/label.js +24 -0
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/separator.js +22 -0
- package/dist/components/ui/sheet.d.ts +23 -0
- package/dist/components/ui/sheet.d.ts.map +1 -0
- package/dist/components/ui/sheet.js +66 -0
- package/dist/components/ui/sidebar.d.ts +66 -0
- package/dist/components/ui/sidebar.d.ts.map +1 -0
- package/dist/components/ui/sidebar.js +267 -0
- package/dist/components/ui/skeleton.d.ts +3 -0
- package/dist/components/ui/skeleton.d.ts.map +1 -0
- package/dist/components/ui/skeleton.js +18 -0
- package/dist/components/ui/sonner.d.ts +5 -0
- package/dist/components/ui/sonner.d.ts.map +1 -0
- package/dist/components/ui/sonner.js +28 -0
- package/dist/components/ui/switch.d.ts +5 -0
- package/dist/components/ui/switch.d.ts.map +1 -0
- package/dist/components/ui/switch.js +22 -0
- package/dist/components/ui/table.d.ts +11 -0
- package/dist/components/ui/table.d.ts.map +1 -0
- package/dist/components/ui/table.js +55 -0
- package/dist/components/ui/tabs.d.ts +8 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/tabs.js +33 -0
- package/dist/components/ui/tooltip.d.ts +8 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip.js +25 -0
- package/dist/components/ui/vertical-tabs.d.ts +8 -0
- package/dist/components/ui/vertical-tabs.d.ts.map +1 -0
- package/dist/components/ui/vertical-tabs.js +37 -0
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +15 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/lib/already_logged_in_config.server.d.ts +14 -0
- package/dist/lib/already_logged_in_config.server.d.ts.map +1 -0
- package/dist/lib/already_logged_in_config.server.js +29 -0
- package/dist/lib/app_logger.d.ts +12 -0
- package/dist/lib/app_logger.d.ts.map +1 -0
- package/dist/lib/app_logger.js +14 -0
- package/dist/lib/auth/auth_cache.d.ts +83 -0
- package/dist/lib/auth/auth_cache.d.ts.map +1 -0
- package/dist/lib/auth/auth_cache.js +158 -0
- package/dist/lib/auth/auth_rate_limiter.d.ts +39 -0
- package/dist/lib/auth/auth_rate_limiter.d.ts.map +1 -0
- package/dist/lib/auth/auth_rate_limiter.js +95 -0
- package/dist/lib/auth/auth_types.d.ts +53 -0
- package/dist/lib/auth/auth_types.d.ts.map +1 -0
- package/dist/lib/auth/auth_types.js +16 -0
- package/dist/lib/auth/auth_utils.server.d.ts +47 -0
- package/dist/lib/auth/auth_utils.server.d.ts.map +1 -0
- package/dist/lib/auth/auth_utils.server.js +150 -0
- package/dist/lib/auth/hazo_get_auth.server.d.ts +12 -0
- package/dist/lib/auth/hazo_get_auth.server.d.ts.map +1 -0
- package/dist/lib/auth/hazo_get_auth.server.js +256 -0
- package/dist/lib/auth/index.d.ts +9 -0
- package/dist/lib/auth/index.d.ts.map +1 -0
- package/dist/lib/auth/index.js +12 -0
- package/dist/lib/auth/server_auth.d.ts +26 -0
- package/dist/lib/auth/server_auth.d.ts.map +1 -0
- package/dist/lib/auth/server_auth.js +62 -0
- package/dist/lib/auth_utility_config.server.d.ts +20 -0
- package/dist/lib/auth_utility_config.server.d.ts.map +1 -0
- package/dist/lib/auth_utility_config.server.js +64 -0
- package/dist/lib/config/config_loader.server.d.ts +44 -0
- package/dist/lib/config/config_loader.server.d.ts.map +1 -0
- package/dist/lib/config/config_loader.server.js +122 -0
- package/dist/lib/email_verification_config.server.d.ts +14 -0
- package/dist/lib/email_verification_config.server.d.ts.map +1 -0
- package/dist/lib/email_verification_config.server.js +20 -0
- package/dist/lib/file_types_config.server.d.ts +11 -0
- package/dist/lib/file_types_config.server.d.ts.map +1 -0
- package/dist/lib/file_types_config.server.js +16 -0
- package/dist/lib/forgot_password_config.server.d.ts +14 -0
- package/dist/lib/forgot_password_config.server.d.ts.map +1 -0
- package/dist/lib/forgot_password_config.server.js +20 -0
- package/dist/lib/hazo_connect_instance.server.d.ts +17 -0
- package/dist/lib/hazo_connect_instance.server.d.ts.map +1 -0
- package/dist/lib/hazo_connect_instance.server.js +88 -0
- package/dist/lib/hazo_connect_setup.d.ts +2 -0
- package/dist/lib/hazo_connect_setup.d.ts.map +1 -0
- package/dist/lib/hazo_connect_setup.js +49 -0
- package/dist/lib/hazo_connect_setup.server.d.ts +20 -0
- package/dist/lib/hazo_connect_setup.server.d.ts.map +1 -0
- package/dist/lib/hazo_connect_setup.server.js +138 -0
- package/dist/lib/index.d.ts +28 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +35 -0
- package/dist/lib/login_config.server.d.ts +20 -0
- package/dist/lib/login_config.server.d.ts.map +1 -0
- package/dist/lib/login_config.server.js +37 -0
- package/dist/lib/messages_config.server.d.ts +13 -0
- package/dist/lib/messages_config.server.d.ts.map +1 -0
- package/dist/lib/messages_config.server.js +18 -0
- package/dist/lib/migrations/apply_migration.d.ts +22 -0
- package/dist/lib/migrations/apply_migration.d.ts.map +1 -0
- package/dist/lib/migrations/apply_migration.js +78 -0
- package/dist/lib/my_settings_config.server.d.ts +65 -0
- package/dist/lib/my_settings_config.server.d.ts.map +1 -0
- package/dist/lib/my_settings_config.server.js +67 -0
- package/dist/lib/password_requirements_config.server.d.ts +15 -0
- package/dist/lib/password_requirements_config.server.d.ts.map +1 -0
- package/dist/lib/password_requirements_config.server.js +26 -0
- package/dist/lib/profile_pic_menu_config.server.d.ts +26 -0
- package/dist/lib/profile_pic_menu_config.server.d.ts.map +1 -0
- package/dist/lib/profile_pic_menu_config.server.js +95 -0
- package/dist/lib/profile_picture_config.server.d.ts +16 -0
- package/dist/lib/profile_picture_config.server.d.ts.map +1 -0
- package/dist/lib/profile_picture_config.server.js +40 -0
- package/dist/lib/register_config.server.d.ts +24 -0
- package/dist/lib/register_config.server.d.ts.map +1 -0
- package/dist/lib/register_config.server.js +39 -0
- package/dist/lib/reset_password_config.server.d.ts +25 -0
- package/dist/lib/reset_password_config.server.d.ts.map +1 -0
- package/dist/lib/reset_password_config.server.js +38 -0
- package/dist/lib/services/email_service.d.ts +44 -0
- package/dist/lib/services/email_service.d.ts.map +1 -0
- package/dist/lib/services/email_service.js +480 -0
- package/dist/lib/services/email_verification_service.d.ts +35 -0
- package/dist/lib/services/email_verification_service.d.ts.map +1 -0
- package/dist/lib/services/email_verification_service.js +208 -0
- package/dist/lib/services/index.d.ts +13 -0
- package/dist/lib/services/index.d.ts.map +1 -0
- package/dist/lib/services/index.js +14 -0
- package/dist/lib/services/login_service.d.ts +20 -0
- package/dist/lib/services/login_service.d.ts.map +1 -0
- package/dist/lib/services/login_service.js +94 -0
- package/dist/lib/services/password_change_service.d.ts +19 -0
- package/dist/lib/services/password_change_service.d.ts.map +1 -0
- package/dist/lib/services/password_change_service.js +118 -0
- package/dist/lib/services/password_reset_service.d.ts +52 -0
- package/dist/lib/services/password_reset_service.d.ts.map +1 -0
- package/dist/lib/services/password_reset_service.js +318 -0
- package/dist/lib/services/profile_picture_remove_service.d.ts +15 -0
- package/dist/lib/services/profile_picture_remove_service.d.ts.map +1 -0
- package/dist/lib/services/profile_picture_remove_service.js +94 -0
- package/dist/lib/services/profile_picture_service.d.ts +45 -0
- package/dist/lib/services/profile_picture_service.d.ts.map +1 -0
- package/dist/lib/services/profile_picture_service.js +183 -0
- package/dist/lib/services/profile_picture_source_mapper.d.ts +23 -0
- package/dist/lib/services/profile_picture_source_mapper.d.ts.map +1 -0
- package/dist/lib/services/profile_picture_source_mapper.js +45 -0
- package/dist/lib/services/registration_service.d.ts +20 -0
- package/dist/lib/services/registration_service.d.ts.map +1 -0
- package/dist/lib/services/registration_service.js +147 -0
- package/dist/lib/services/token_service.d.ts +20 -0
- package/dist/lib/services/token_service.d.ts.map +1 -0
- package/dist/lib/services/token_service.js +201 -0
- package/dist/lib/services/user_profiles_service.d.ts +31 -0
- package/dist/lib/services/user_profiles_service.d.ts.map +1 -0
- package/dist/lib/services/user_profiles_service.js +99 -0
- package/dist/lib/services/user_update_service.d.ts +23 -0
- package/dist/lib/services/user_update_service.d.ts.map +1 -0
- package/dist/lib/services/user_update_service.js +103 -0
- package/dist/lib/ui_shell_config.server.d.ts +16 -0
- package/dist/lib/ui_shell_config.server.d.ts.map +1 -0
- package/dist/lib/ui_shell_config.server.js +28 -0
- package/dist/lib/ui_sizes_config.server.d.ts +17 -0
- package/dist/lib/ui_sizes_config.server.d.ts.map +1 -0
- package/dist/lib/ui_sizes_config.server.js +22 -0
- package/dist/lib/user_fields_config.server.d.ts +13 -0
- package/dist/lib/user_fields_config.server.d.ts.map +1 -0
- package/dist/lib/user_fields_config.server.js +21 -0
- package/dist/lib/user_management_config.server.d.ts +10 -0
- package/dist/lib/user_management_config.server.d.ts.map +1 -0
- package/dist/lib/user_management_config.server.js +26 -0
- package/dist/lib/utils/api_route_helpers.d.ts +13 -0
- package/dist/lib/utils/api_route_helpers.d.ts.map +1 -0
- package/dist/lib/utils/api_route_helpers.js +58 -0
- package/dist/lib/utils/error_sanitizer.d.ts +16 -0
- package/dist/lib/utils/error_sanitizer.d.ts.map +1 -0
- package/dist/lib/utils/error_sanitizer.js +39 -0
- package/dist/lib/utils.d.ts +4 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +9 -0
- package/dist/server/config/config_loader.d.ts +26 -0
- package/dist/server/config/config_loader.d.ts.map +1 -0
- package/dist/server/config/config_loader.js +329 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +32 -0
- package/dist/server/logging/logger_service.d.ts +3 -0
- package/dist/server/logging/logger_service.d.ts.map +1 -0
- package/dist/server/logging/logger_service.js +37 -0
- package/dist/server/routes/root_router.d.ts +3 -0
- package/dist/server/routes/root_router.d.ts.map +1 -0
- package/dist/server/routes/root_router.js +14 -0
- package/dist/server/server.d.ts +3 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +25 -0
- package/dist/server/types/app_types.d.ts +53 -0
- package/dist/server/types/app_types.d.ts.map +1 -0
- package/dist/server/types/app_types.js +1 -0
- package/migrations/003_add_url_on_logon_to_hazo_users.sql +8 -0
- package/next.config.mjs +12 -0
- package/package.json +39 -2
- package/scripts/init_users.ts +9 -9
- package/src/components/index.ts +7 -0
- package/src/components/layouts/email_verification/config/email_verification_field_config.ts +2 -2
- package/src/components/layouts/email_verification/hooks/use_email_verification.ts +3 -3
- package/src/components/layouts/email_verification/index.tsx +11 -11
- package/src/components/layouts/forgot_password/config/forgot_password_field_config.ts +2 -2
- package/src/components/layouts/forgot_password/hooks/use_forgot_password_form.ts +3 -3
- package/src/components/layouts/forgot_password/index.tsx +10 -10
- package/src/components/layouts/index.ts +26 -0
- package/src/components/layouts/login/config/login_field_config.ts +2 -2
- package/src/components/layouts/login/hooks/use_login_form.ts +5 -5
- package/src/components/layouts/login/index.tsx +11 -11
- package/src/components/layouts/my_settings/components/editable_field.tsx +3 -3
- package/src/components/layouts/my_settings/components/password_change_dialog.tsx +5 -5
- package/src/components/layouts/my_settings/components/profile_picture_dialog.tsx +7 -7
- package/src/components/layouts/my_settings/components/profile_picture_display.tsx +2 -2
- package/src/components/layouts/my_settings/components/profile_picture_gravatar_tab.tsx +3 -3
- package/src/components/layouts/my_settings/components/profile_picture_library_tab.tsx +5 -5
- package/src/components/layouts/my_settings/components/profile_picture_upload_tab.tsx +4 -4
- package/src/components/layouts/my_settings/config/my_settings_field_config.ts +2 -2
- package/src/components/layouts/my_settings/hooks/use_my_settings.ts +2 -2
- package/src/components/layouts/my_settings/index.tsx +10 -10
- package/src/components/layouts/register/config/register_field_config.ts +2 -2
- package/src/components/layouts/register/hooks/use_register_form.ts +4 -4
- package/src/components/layouts/register/index.tsx +11 -11
- package/src/components/layouts/reset_password/config/reset_password_field_config.ts +2 -2
- package/src/components/layouts/reset_password/hooks/use_reset_password_form.ts +4 -4
- package/src/components/layouts/reset_password/index.tsx +10 -10
- package/src/components/layouts/shared/components/already_logged_in_guard.tsx +4 -4
- package/src/components/layouts/shared/components/auth_page_shell.tsx +3 -3
- package/src/components/layouts/shared/components/form_action_buttons.tsx +2 -2
- package/src/components/layouts/shared/components/form_field_wrapper.tsx +2 -2
- package/src/components/layouts/shared/components/logout_button.tsx +2 -2
- package/src/components/layouts/shared/components/password_field.tsx +3 -3
- package/src/components/layouts/shared/components/profile_pic_menu.tsx +5 -5
- package/src/components/layouts/shared/components/profile_pic_menu_wrapper.tsx +2 -2
- package/src/components/layouts/shared/components/sidebar_layout_wrapper.tsx +3 -3
- package/src/components/layouts/shared/components/standalone_layout_wrapper.tsx +1 -1
- package/src/components/layouts/shared/components/two_column_auth_layout.tsx +1 -1
- package/src/components/layouts/shared/components/unauthorized_guard.tsx +2 -2
- package/src/components/layouts/shared/hooks/use_hazo_auth.ts +1 -1
- package/src/components/layouts/shared/index.ts +34 -0
- package/src/components/layouts/shared/utils/validation.ts +1 -1
- package/src/components/layouts/user_management/components/roles_matrix.tsx +7 -7
- package/src/components/layouts/user_management/index.tsx +11 -11
- package/src/components/ui/alert-dialog.tsx +2 -2
- package/src/components/ui/avatar.tsx +1 -1
- package/src/components/ui/button.tsx +1 -1
- package/src/components/ui/checkbox.tsx +1 -1
- package/src/components/ui/dialog.tsx +1 -1
- package/src/components/ui/dropdown-menu.tsx +1 -1
- package/src/components/ui/hazo_ui_tooltip.tsx +1 -1
- package/src/components/ui/index.ts +22 -0
- package/src/components/ui/input.tsx +1 -1
- package/src/components/ui/label.tsx +1 -1
- package/src/components/ui/separator.tsx +1 -1
- package/src/components/ui/sheet.tsx +1 -1
- package/src/components/ui/sidebar.tsx +8 -8
- package/src/components/ui/skeleton.tsx +1 -1
- package/src/components/ui/switch.tsx +1 -1
- package/src/components/ui/table.tsx +1 -1
- package/src/components/ui/tabs.tsx +1 -1
- package/src/components/ui/tooltip.tsx +1 -1
- package/src/components/ui/vertical-tabs.tsx +1 -1
- package/src/index.ts +7 -0
- package/src/lib/already_logged_in_config.server.ts +1 -1
- package/src/lib/app_logger.ts +1 -1
- package/src/lib/auth/auth_cache.ts +1 -1
- package/src/lib/auth/auth_utils.server.ts +2 -2
- package/src/lib/auth/hazo_get_auth.server.ts +8 -8
- package/src/lib/auth/index.ts +23 -0
- package/src/lib/auth/server_auth.ts +2 -2
- package/src/lib/auth_utility_config.server.ts +1 -1
- package/src/lib/config/config_loader.server.ts +1 -1
- package/src/lib/email_verification_config.server.ts +1 -1
- package/src/lib/file_types_config.server.ts +1 -1
- package/src/lib/forgot_password_config.server.ts +1 -1
- package/src/lib/hazo_connect_instance.server.ts +2 -2
- package/src/lib/hazo_connect_setup.server.ts +2 -2
- package/src/lib/index.ts +44 -0
- package/src/lib/login_config.server.ts +2 -2
- package/src/lib/messages_config.server.ts +1 -1
- package/src/lib/my_settings_config.server.ts +7 -7
- package/src/lib/password_requirements_config.server.ts +1 -1
- package/src/lib/profile_pic_menu_config.server.ts +1 -1
- package/src/lib/profile_picture_config.server.ts +2 -2
- package/src/lib/register_config.server.ts +4 -4
- package/src/lib/reset_password_config.server.ts +3 -3
- package/src/lib/services/email_service.ts +2 -2
- package/src/lib/services/email_verification_service.ts +3 -3
- package/src/lib/services/index.ts +15 -0
- package/src/lib/services/login_service.ts +3 -3
- package/src/lib/services/password_change_service.ts +3 -3
- package/src/lib/services/password_reset_service.ts +3 -3
- package/src/lib/services/profile_picture_remove_service.ts +3 -3
- package/src/lib/services/profile_picture_service.ts +5 -5
- package/src/lib/services/registration_service.ts +8 -8
- package/src/lib/services/token_service.ts +2 -2
- package/src/lib/services/user_profiles_service.ts +2 -2
- package/src/lib/services/user_update_service.ts +4 -4
- package/src/lib/ui_shell_config.server.ts +1 -1
- package/src/lib/ui_sizes_config.server.ts +1 -1
- package/src/lib/user_fields_config.server.ts +1 -1
- package/src/lib/user_management_config.server.ts +1 -2
- package/src/lib/utils/error_sanitizer.ts +1 -1
- package/src/routes/index.ts +34 -0
- package/src/server/config/config_loader.ts +2 -2
- package/src/server/index.ts +2 -2
- package/src/server/logging/logger_service.ts +1 -1
- package/src/server/server.ts +2 -2
- package/src/server/types/express.d.ts +1 -1
- package/tsconfig.build.json +39 -0
- package/tsconfig.json +5 -1
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
// file_description: hook for managing my settings state and API calls
|
|
2
|
+
// section: client_directive
|
|
3
|
+
"use client";
|
|
4
|
+
// section: imports
|
|
5
|
+
import { useState, useCallback } from "react";
|
|
6
|
+
import { use_auth_status, trigger_auth_status_refresh } from "hazo_auth/components/layouts/shared/hooks/use_auth_status";
|
|
7
|
+
import { toast } from "sonner";
|
|
8
|
+
// section: helpers
|
|
9
|
+
/**
|
|
10
|
+
* Validates email format
|
|
11
|
+
*/
|
|
12
|
+
const validateEmail = (email) => {
|
|
13
|
+
if (!email || email.trim() === "") {
|
|
14
|
+
return "Email is required";
|
|
15
|
+
}
|
|
16
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
17
|
+
if (!emailRegex.test(email)) {
|
|
18
|
+
return "Invalid email address format";
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Validates name (optional, but if provided should not be empty)
|
|
24
|
+
*/
|
|
25
|
+
const validateName = (name) => {
|
|
26
|
+
if (name.trim() === "") {
|
|
27
|
+
return "Name cannot be empty";
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
// section: hook
|
|
32
|
+
/**
|
|
33
|
+
* Hook for managing my settings state and API calls
|
|
34
|
+
* Handles user data loading, field editing, and API calls for updates
|
|
35
|
+
* @param params - Hook parameters including password requirements
|
|
36
|
+
* @returns My settings hook result with state and actions
|
|
37
|
+
*/
|
|
38
|
+
export function use_my_settings({ passwordRequirements, }) {
|
|
39
|
+
const authStatus = use_auth_status();
|
|
40
|
+
// Password fields state
|
|
41
|
+
const [passwordFields, setPasswordFields] = useState({
|
|
42
|
+
currentPassword: "",
|
|
43
|
+
newPassword: "",
|
|
44
|
+
confirmPassword: "",
|
|
45
|
+
currentPasswordVisible: false,
|
|
46
|
+
newPasswordVisible: false,
|
|
47
|
+
confirmPasswordVisible: false,
|
|
48
|
+
errors: {},
|
|
49
|
+
});
|
|
50
|
+
// Get user data from auth status
|
|
51
|
+
const name = authStatus.name || "";
|
|
52
|
+
const email = authStatus.email || "";
|
|
53
|
+
const profilePictureUrl = authStatus.profile_picture_url;
|
|
54
|
+
const profileSource = authStatus.profile_source;
|
|
55
|
+
const lastLogon = authStatus.last_logon;
|
|
56
|
+
const loading = authStatus.loading;
|
|
57
|
+
/**
|
|
58
|
+
* Refreshes user data by triggering auth status refresh
|
|
59
|
+
*/
|
|
60
|
+
const refreshUserData = useCallback(async () => {
|
|
61
|
+
trigger_auth_status_refresh();
|
|
62
|
+
// Also call the refresh method directly
|
|
63
|
+
await authStatus.refresh();
|
|
64
|
+
}, [authStatus]);
|
|
65
|
+
/**
|
|
66
|
+
* Updates user name
|
|
67
|
+
*/
|
|
68
|
+
const handleNameSave = useCallback(async (value) => {
|
|
69
|
+
const validationError = validateName(value);
|
|
70
|
+
if (validationError) {
|
|
71
|
+
toast.error(validationError);
|
|
72
|
+
throw new Error(validationError);
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const response = await fetch("/api/hazo_auth/update_user", {
|
|
76
|
+
method: "PATCH",
|
|
77
|
+
headers: {
|
|
78
|
+
"Content-Type": "application/json",
|
|
79
|
+
},
|
|
80
|
+
credentials: "include",
|
|
81
|
+
body: JSON.stringify({ name: value }),
|
|
82
|
+
});
|
|
83
|
+
const data = await response.json();
|
|
84
|
+
if (!response.ok || !data.success) {
|
|
85
|
+
const errorMessage = data.error || "Failed to update name";
|
|
86
|
+
toast.error(errorMessage);
|
|
87
|
+
throw new Error(errorMessage);
|
|
88
|
+
}
|
|
89
|
+
toast.success("Name updated successfully");
|
|
90
|
+
await refreshUserData();
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
const errorMessage = error instanceof Error ? error.message : "Failed to update name";
|
|
94
|
+
toast.error(errorMessage);
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
}, [refreshUserData]);
|
|
98
|
+
/**
|
|
99
|
+
* Updates user email
|
|
100
|
+
*/
|
|
101
|
+
const handleEmailSave = useCallback(async (value) => {
|
|
102
|
+
const validationError = validateEmail(value);
|
|
103
|
+
if (validationError) {
|
|
104
|
+
toast.error(validationError);
|
|
105
|
+
throw new Error(validationError);
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const response = await fetch("/api/hazo_auth/update_user", {
|
|
109
|
+
method: "PATCH",
|
|
110
|
+
headers: {
|
|
111
|
+
"Content-Type": "application/json",
|
|
112
|
+
},
|
|
113
|
+
credentials: "include",
|
|
114
|
+
body: JSON.stringify({ email: value }),
|
|
115
|
+
});
|
|
116
|
+
const data = await response.json();
|
|
117
|
+
if (!response.ok || !data.success) {
|
|
118
|
+
const errorMessage = data.error || "Failed to update email";
|
|
119
|
+
toast.error(errorMessage);
|
|
120
|
+
throw new Error(errorMessage);
|
|
121
|
+
}
|
|
122
|
+
if (data.email_changed) {
|
|
123
|
+
toast.success("Email updated successfully. Please verify your new email address.");
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
toast.success("Email updated successfully");
|
|
127
|
+
}
|
|
128
|
+
await refreshUserData();
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
const errorMessage = error instanceof Error ? error.message : "Failed to update email";
|
|
132
|
+
toast.error(errorMessage);
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
}, [refreshUserData]);
|
|
136
|
+
/**
|
|
137
|
+
* Validates password requirements
|
|
138
|
+
*/
|
|
139
|
+
const validatePassword = useCallback((password) => {
|
|
140
|
+
if (!password || password.length < passwordRequirements.minimum_length) {
|
|
141
|
+
return `Password must be at least ${passwordRequirements.minimum_length} characters long`;
|
|
142
|
+
}
|
|
143
|
+
const errors = [];
|
|
144
|
+
if (passwordRequirements.require_uppercase && !/[A-Z]/.test(password)) {
|
|
145
|
+
errors.push("uppercase letter");
|
|
146
|
+
}
|
|
147
|
+
if (passwordRequirements.require_lowercase && !/[a-z]/.test(password)) {
|
|
148
|
+
errors.push("lowercase letter");
|
|
149
|
+
}
|
|
150
|
+
if (passwordRequirements.require_number && !/[0-9]/.test(password)) {
|
|
151
|
+
errors.push("number");
|
|
152
|
+
}
|
|
153
|
+
if (passwordRequirements.require_special && !/[^A-Za-z0-9]/.test(password)) {
|
|
154
|
+
errors.push("special character");
|
|
155
|
+
}
|
|
156
|
+
if (errors.length > 0) {
|
|
157
|
+
return `Password must contain at least one: ${errors.join(", ")}`;
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
}, [passwordRequirements]);
|
|
161
|
+
/**
|
|
162
|
+
* Handles password field change
|
|
163
|
+
*/
|
|
164
|
+
const handlePasswordFieldChange = useCallback((field, value) => {
|
|
165
|
+
setPasswordFields((prev) => {
|
|
166
|
+
const newFields = Object.assign(Object.assign({}, prev), { [field]: value });
|
|
167
|
+
// Clear errors for this field when user types
|
|
168
|
+
if (newFields.errors[field]) {
|
|
169
|
+
newFields.errors = Object.assign(Object.assign({}, newFields.errors), { [field]: undefined });
|
|
170
|
+
}
|
|
171
|
+
return newFields;
|
|
172
|
+
});
|
|
173
|
+
}, []);
|
|
174
|
+
/**
|
|
175
|
+
* Toggles password visibility
|
|
176
|
+
*/
|
|
177
|
+
const togglePasswordVisibility = useCallback((field) => {
|
|
178
|
+
setPasswordFields((prev) => {
|
|
179
|
+
const fieldKey = `${field}Visible`;
|
|
180
|
+
const currentValue = prev[fieldKey];
|
|
181
|
+
return Object.assign(Object.assign({}, prev), { [fieldKey]: !currentValue });
|
|
182
|
+
});
|
|
183
|
+
}, []);
|
|
184
|
+
/**
|
|
185
|
+
* Validates password form
|
|
186
|
+
*/
|
|
187
|
+
const validatePasswordForm = useCallback(() => {
|
|
188
|
+
const errors = {};
|
|
189
|
+
if (!passwordFields.currentPassword) {
|
|
190
|
+
errors.currentPassword = "Current password is required";
|
|
191
|
+
}
|
|
192
|
+
const newPasswordError = validatePassword(passwordFields.newPassword);
|
|
193
|
+
if (newPasswordError) {
|
|
194
|
+
errors.newPassword = newPasswordError;
|
|
195
|
+
}
|
|
196
|
+
if (!passwordFields.confirmPassword) {
|
|
197
|
+
errors.confirmPassword = "Please confirm your new password";
|
|
198
|
+
}
|
|
199
|
+
else if (passwordFields.newPassword !== passwordFields.confirmPassword) {
|
|
200
|
+
errors.confirmPassword = "Passwords do not match";
|
|
201
|
+
}
|
|
202
|
+
setPasswordFields((prev) => (Object.assign(Object.assign({}, prev), { errors })));
|
|
203
|
+
return Object.keys(errors).length === 0;
|
|
204
|
+
}, [passwordFields, validatePassword]);
|
|
205
|
+
/**
|
|
206
|
+
* Checks if password save should be disabled
|
|
207
|
+
*/
|
|
208
|
+
const isPasswordSaveDisabled = useCallback(() => {
|
|
209
|
+
return !passwordFields.currentPassword || !passwordFields.newPassword || !passwordFields.confirmPassword;
|
|
210
|
+
}, [passwordFields]);
|
|
211
|
+
/**
|
|
212
|
+
* Saves password changes
|
|
213
|
+
*/
|
|
214
|
+
const handlePasswordSave = useCallback(async () => {
|
|
215
|
+
if (!validatePasswordForm()) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
try {
|
|
219
|
+
const response = await fetch("/api/hazo_auth/change_password", {
|
|
220
|
+
method: "POST",
|
|
221
|
+
headers: {
|
|
222
|
+
"Content-Type": "application/json",
|
|
223
|
+
},
|
|
224
|
+
credentials: "include",
|
|
225
|
+
body: JSON.stringify({
|
|
226
|
+
current_password: passwordFields.currentPassword,
|
|
227
|
+
new_password: passwordFields.newPassword,
|
|
228
|
+
}),
|
|
229
|
+
});
|
|
230
|
+
const data = await response.json();
|
|
231
|
+
if (!response.ok || !data.success) {
|
|
232
|
+
const errorMessage = data.error || "Failed to change password";
|
|
233
|
+
setPasswordFields((prev) => (Object.assign(Object.assign({}, prev), { errors: { currentPassword: errorMessage } })));
|
|
234
|
+
toast.error(errorMessage);
|
|
235
|
+
throw new Error(errorMessage);
|
|
236
|
+
}
|
|
237
|
+
toast.success("Password changed successfully");
|
|
238
|
+
// Reset password fields
|
|
239
|
+
setPasswordFields({
|
|
240
|
+
currentPassword: "",
|
|
241
|
+
newPassword: "",
|
|
242
|
+
confirmPassword: "",
|
|
243
|
+
currentPasswordVisible: false,
|
|
244
|
+
newPasswordVisible: false,
|
|
245
|
+
confirmPasswordVisible: false,
|
|
246
|
+
errors: {},
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
const errorMessage = error instanceof Error ? error.message : "Failed to change password";
|
|
251
|
+
toast.error(errorMessage);
|
|
252
|
+
throw error;
|
|
253
|
+
}
|
|
254
|
+
}, [passwordFields, validatePasswordForm]);
|
|
255
|
+
/**
|
|
256
|
+
* Profile picture dialog state
|
|
257
|
+
*/
|
|
258
|
+
const [profilePictureDialogOpen, setProfilePictureDialogOpen] = useState(false);
|
|
259
|
+
/**
|
|
260
|
+
* Opens profile picture dialog
|
|
261
|
+
*/
|
|
262
|
+
const handleProfilePictureEdit = useCallback(() => {
|
|
263
|
+
setProfilePictureDialogOpen(true);
|
|
264
|
+
}, []);
|
|
265
|
+
/**
|
|
266
|
+
* Closes profile picture dialog
|
|
267
|
+
*/
|
|
268
|
+
const handleProfilePictureDialogClose = useCallback(() => {
|
|
269
|
+
setProfilePictureDialogOpen(false);
|
|
270
|
+
}, []);
|
|
271
|
+
/**
|
|
272
|
+
* Saves profile picture changes
|
|
273
|
+
* Note: profilePictureUrl is already a fully-formed URL (Gravatar URL is generated in the dialog)
|
|
274
|
+
*/
|
|
275
|
+
const handleProfilePictureSave = useCallback(async (profilePictureUrl, profileSource) => {
|
|
276
|
+
try {
|
|
277
|
+
const response = await fetch("/api/hazo_auth/update_user", {
|
|
278
|
+
method: "PATCH",
|
|
279
|
+
headers: {
|
|
280
|
+
"Content-Type": "application/json",
|
|
281
|
+
},
|
|
282
|
+
credentials: "include",
|
|
283
|
+
body: JSON.stringify({
|
|
284
|
+
profile_picture_url: profilePictureUrl,
|
|
285
|
+
profile_source: profileSource,
|
|
286
|
+
}),
|
|
287
|
+
});
|
|
288
|
+
const data = await response.json();
|
|
289
|
+
if (!response.ok || !data.success) {
|
|
290
|
+
const errorMessage = data.error || "Failed to update profile picture";
|
|
291
|
+
toast.error(errorMessage);
|
|
292
|
+
throw new Error(errorMessage);
|
|
293
|
+
}
|
|
294
|
+
toast.success("Profile picture updated successfully");
|
|
295
|
+
await refreshUserData();
|
|
296
|
+
setProfilePictureDialogOpen(false);
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
const errorMessage = error instanceof Error ? error.message : "Failed to update profile picture";
|
|
300
|
+
toast.error(errorMessage);
|
|
301
|
+
throw error;
|
|
302
|
+
}
|
|
303
|
+
}, [refreshUserData]);
|
|
304
|
+
/**
|
|
305
|
+
* Removes profile picture
|
|
306
|
+
* - If upload: deletes the file and clears profile_picture_url and profile_source
|
|
307
|
+
* - If gravatar/library: clears profile_picture_url and profile_source
|
|
308
|
+
*/
|
|
309
|
+
const handleProfilePictureRemove = useCallback(async () => {
|
|
310
|
+
try {
|
|
311
|
+
const response = await fetch("/api/hazo_auth/remove_profile_picture", {
|
|
312
|
+
method: "DELETE",
|
|
313
|
+
headers: {
|
|
314
|
+
"Content-Type": "application/json",
|
|
315
|
+
},
|
|
316
|
+
credentials: "include",
|
|
317
|
+
});
|
|
318
|
+
const data = await response.json();
|
|
319
|
+
if (!response.ok || !data.success) {
|
|
320
|
+
const errorMessage = data.error || "Failed to remove profile picture";
|
|
321
|
+
toast.error(errorMessage);
|
|
322
|
+
throw new Error(errorMessage);
|
|
323
|
+
}
|
|
324
|
+
toast.success("Profile picture removed successfully");
|
|
325
|
+
await refreshUserData();
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
const errorMessage = error instanceof Error ? error.message : "Failed to remove profile picture";
|
|
329
|
+
toast.error(errorMessage);
|
|
330
|
+
throw error;
|
|
331
|
+
}
|
|
332
|
+
}, [refreshUserData]);
|
|
333
|
+
return {
|
|
334
|
+
name,
|
|
335
|
+
email,
|
|
336
|
+
profilePictureUrl,
|
|
337
|
+
profileSource,
|
|
338
|
+
lastLogon,
|
|
339
|
+
loading,
|
|
340
|
+
passwordFields,
|
|
341
|
+
handlePasswordFieldChange,
|
|
342
|
+
togglePasswordVisibility,
|
|
343
|
+
handlePasswordSave,
|
|
344
|
+
isPasswordSaveDisabled: isPasswordSaveDisabled(),
|
|
345
|
+
profilePictureDialogOpen,
|
|
346
|
+
handleProfilePictureEdit,
|
|
347
|
+
handleProfilePictureDialogClose,
|
|
348
|
+
handleProfilePictureSave,
|
|
349
|
+
handleProfilePictureRemove,
|
|
350
|
+
handleNameSave,
|
|
351
|
+
handleEmailSave,
|
|
352
|
+
refreshUserData,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type MySettingsLabelOverrides } from "hazo_auth/components/layouts/my_settings/config/my_settings_field_config";
|
|
2
|
+
import type { PasswordRequirementOptions, ButtonPaletteOverrides } from "hazo_auth/components/layouts/shared/config/layout_customization";
|
|
3
|
+
export type MySettingsLayoutProps = {
|
|
4
|
+
labels?: MySettingsLabelOverrides;
|
|
5
|
+
button_colors?: ButtonPaletteOverrides;
|
|
6
|
+
password_requirements: PasswordRequirementOptions;
|
|
7
|
+
profilePicture: {
|
|
8
|
+
allow_photo_upload: boolean;
|
|
9
|
+
upload_photo_path?: string;
|
|
10
|
+
max_photo_size: number;
|
|
11
|
+
user_photo_default: boolean;
|
|
12
|
+
user_photo_default_priority1: "gravatar" | "library";
|
|
13
|
+
user_photo_default_priority2?: "library" | "gravatar";
|
|
14
|
+
library_photo_path: string;
|
|
15
|
+
};
|
|
16
|
+
userFields: {
|
|
17
|
+
show_name_field: boolean;
|
|
18
|
+
show_email_field: boolean;
|
|
19
|
+
show_password_field: boolean;
|
|
20
|
+
};
|
|
21
|
+
unauthorizedMessage?: string;
|
|
22
|
+
loginButtonLabel?: string;
|
|
23
|
+
loginPath?: string;
|
|
24
|
+
heading?: string;
|
|
25
|
+
subHeading?: string;
|
|
26
|
+
profilePhotoLabel?: string;
|
|
27
|
+
profilePhotoRecommendation?: string;
|
|
28
|
+
uploadPhotoButtonLabel?: string;
|
|
29
|
+
removePhotoButtonLabel?: string;
|
|
30
|
+
profileInformationLabel?: string;
|
|
31
|
+
passwordLabel?: string;
|
|
32
|
+
currentPasswordLabel?: string;
|
|
33
|
+
newPasswordLabel?: string;
|
|
34
|
+
confirmPasswordLabel?: string;
|
|
35
|
+
messages: {
|
|
36
|
+
photo_upload_disabled_message: string;
|
|
37
|
+
gravatar_setup_message: string;
|
|
38
|
+
gravatar_no_account_message: string;
|
|
39
|
+
library_tooltip_message: string;
|
|
40
|
+
};
|
|
41
|
+
uiSizes: {
|
|
42
|
+
gravatar_size: number;
|
|
43
|
+
profile_picture_size: number;
|
|
44
|
+
tooltip_icon_size_default: number;
|
|
45
|
+
tooltip_icon_size_small: number;
|
|
46
|
+
library_photo_grid_columns: number;
|
|
47
|
+
library_photo_preview_size: number;
|
|
48
|
+
image_compression_max_dimension: number;
|
|
49
|
+
upload_file_hard_limit_bytes: number;
|
|
50
|
+
};
|
|
51
|
+
fileTypes: {
|
|
52
|
+
allowed_image_extensions: string[];
|
|
53
|
+
allowed_image_mime_types: string[];
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* My Settings layout component with tabs for profile and security settings
|
|
58
|
+
* Shows editable fields for name, email, and password change dialog
|
|
59
|
+
* Displays profile picture and last logged in information
|
|
60
|
+
* @param props - Component props including labels, button colors, password requirements, etc.
|
|
61
|
+
* @returns My settings layout component
|
|
62
|
+
*/
|
|
63
|
+
export default function my_settings_layout({ labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage, loginButtonLabel, loginPath, heading, subHeading, profilePhotoLabel, profilePhotoRecommendation, uploadPhotoButtonLabel, removePhotoButtonLabel, profileInformationLabel, passwordLabel, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, messages, uiSizes, fileTypes, }: MySettingsLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
64
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/my_settings/index.tsx"],"names":[],"mappings":"AAWA,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,0EAA0E,CAAC;AAClF,OAAO,KAAK,EACV,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,iEAAiE,CAAC;AAOzE,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,qBAAqB,EAAE,0BAA0B,CAAC;IAClD,cAAc,EAAE;QACd,kBAAkB,EAAE,OAAO,CAAC;QAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,4BAA4B,EAAE,UAAU,GAAG,SAAS,CAAC;QACrD,4BAA4B,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;QACtD,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,UAAU,EAAE;QACV,eAAe,EAAE,OAAO,CAAC;QACzB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,mBAAmB,EAAE,OAAO,CAAC;KAC9B,CAAC;IACF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,EAAE;QACR,6BAA6B,EAAE,MAAM,CAAC;QACtC,sBAAsB,EAAE,MAAM,CAAC;QAC/B,2BAA2B,EAAE,MAAM,CAAC;QACpC,uBAAuB,EAAE,MAAM,CAAC;KACjC,CAAC;IACF,OAAO,EAAE;QACP,aAAa,EAAE,MAAM,CAAC;QACtB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,yBAAyB,EAAE,MAAM,CAAC;QAClC,uBAAuB,EAAE,MAAM,CAAC;QAChC,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;QACnC,+BAA+B,EAAE,MAAM,CAAC;QACxC,4BAA4B,EAAE,MAAM,CAAC;KACtC,CAAC;IACF,SAAS,EAAE;QACT,wBAAwB,EAAE,MAAM,EAAE,CAAC;QACnC,wBAAwB,EAAE,MAAM,EAAE,CAAC;KACpC,CAAC;CACH,CAAC;AAGF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,UAAU,EACV,mBAAkE,EAClE,gBAAgC,EAChC,SAA8B,EAC9B,OAA4B,EAC5B,UAAoE,EACpE,iBAAmC,EACnC,0BAAqE,EACrE,sBAA2C,EAC3C,sBAAiC,EACjC,uBAA+C,EAC/C,aAA0B,EAC1B,oBAAyC,EACzC,gBAAiC,EACjC,oBAAyC,EACzC,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE,qBAAqB,2CAqNvB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// file_description: my settings layout component with tabs for profile and security settings
|
|
2
|
+
// section: client_directive
|
|
3
|
+
"use client";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
// section: imports
|
|
6
|
+
import { Button } from "hazo_auth/components/ui/button";
|
|
7
|
+
import { EditableField } from "hazo_auth/components/layouts/my_settings/components/editable_field";
|
|
8
|
+
import { ProfilePictureDisplay } from "hazo_auth/components/layouts/my_settings/components/profile_picture_display";
|
|
9
|
+
import { ProfilePictureDialog } from "hazo_auth/components/layouts/my_settings/components/profile_picture_dialog";
|
|
10
|
+
import { UnauthorizedGuard } from "hazo_auth/components/layouts/shared/components/unauthorized_guard";
|
|
11
|
+
import { use_my_settings } from "hazo_auth/components/layouts/my_settings/hooks/use_my_settings";
|
|
12
|
+
import { resolveMySettingsLabels, resolveMySettingsButtonPalette, } from "hazo_auth/components/layouts/my_settings/config/my_settings_field_config";
|
|
13
|
+
import { PasswordField } from "hazo_auth/components/layouts/shared/components/password_field";
|
|
14
|
+
import { FormFieldWrapper } from "hazo_auth/components/layouts/shared/components/form_field_wrapper";
|
|
15
|
+
import { Pencil, Trash2 } from "lucide-react";
|
|
16
|
+
// section: component
|
|
17
|
+
/**
|
|
18
|
+
* My Settings layout component with tabs for profile and security settings
|
|
19
|
+
* Shows editable fields for name, email, and password change dialog
|
|
20
|
+
* Displays profile picture and last logged in information
|
|
21
|
+
* @param props - Component props including labels, button colors, password requirements, etc.
|
|
22
|
+
* @returns My settings layout component
|
|
23
|
+
*/
|
|
24
|
+
export default function my_settings_layout({ labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage = "You must be logged in to access this page.", loginButtonLabel = "Go to login", loginPath = "/hazo_auth/login", heading = "Account Settings", subHeading = "Manage your profile, password, and email preferences.", profilePhotoLabel = "Profile Photo", profilePhotoRecommendation = "Recommended size: 200x200px. JPG, PNG.", uploadPhotoButtonLabel = "Upload New Photo", removePhotoButtonLabel = "Remove", profileInformationLabel = "Profile Information", passwordLabel = "Password", currentPasswordLabel = "Current Password", newPasswordLabel = "New Password", confirmPasswordLabel = "Confirm Password", messages, uiSizes, fileTypes, }) {
|
|
25
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
26
|
+
const resolvedLabels = resolveMySettingsLabels(labels);
|
|
27
|
+
const resolvedButtonPalette = resolveMySettingsButtonPalette(button_colors);
|
|
28
|
+
const settings = use_my_settings({
|
|
29
|
+
passwordRequirements: password_requirements,
|
|
30
|
+
});
|
|
31
|
+
return (_jsx(UnauthorizedGuard, { message: unauthorizedMessage, loginButtonLabel: loginButtonLabel, loginPath: loginPath, children: _jsxs("div", { className: "cls_my_settings_layout flex flex-col gap-6 p-6 max-w-4xl mx-auto min-h-screen bg-slate-50", children: [_jsxs("div", { className: "cls_my_settings_layout_header flex flex-col gap-2", children: [_jsx("h1", { className: "cls_my_settings_layout_heading text-3xl font-bold text-slate-900", children: heading }), _jsx("p", { className: "cls_my_settings_layout_subheading text-slate-600", children: subHeading })] }), _jsxs("div", { className: "cls_my_settings_layout_profile_photo_section bg-white rounded-lg border border-slate-200 p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-slate-900 mb-4", children: profilePhotoLabel }), _jsx("div", { className: "cls_my_settings_layout_profile_photo_content flex flex-col items-center", children: _jsxs("div", { className: "cls_my_settings_layout_profile_photo_display relative", children: [_jsx(ProfilePictureDisplay, { profilePictureUrl: settings.profilePictureUrl, name: settings.name, email: settings.email, onEdit: settings.handleProfilePictureEdit }), _jsxs("div", { className: "cls_my_settings_layout_profile_photo_actions absolute left-0 right-0 flex items-center justify-between px-2", style: { bottom: '-20px' }, children: [_jsx(Button, { type: "button", onClick: settings.handleProfilePictureEdit, disabled: settings.loading, variant: "ghost", size: "icon", className: "cls_my_settings_layout_upload_photo_button", "aria-label": uploadPhotoButtonLabel, children: _jsx(Pencil, { className: "h-4 w-4", "aria-hidden": "true" }) }), _jsx(Button, { type: "button", onClick: settings.handleProfilePictureRemove, disabled: settings.loading || !settings.profilePictureUrl, variant: "ghost", size: "icon", className: "cls_my_settings_layout_remove_photo_button text-red-600 hover:text-red-700 hover:bg-red-50", "aria-label": removePhotoButtonLabel, children: _jsx(Trash2, { className: "h-4 w-4", "aria-hidden": "true" }) })] })] }) })] }), _jsxs("div", { className: "cls_my_settings_layout_profile_information_section bg-white rounded-lg border border-slate-200 p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-slate-900 mb-4", children: profileInformationLabel }), _jsxs("div", { className: "cls_my_settings_layout_profile_information_fields grid grid-cols-1 md:grid-cols-2 gap-6", children: [userFields.show_name_field && (_jsx(EditableField, { label: "Full Name", value: settings.name, type: "text", placeholder: "Enter your full name", onSave: settings.handleNameSave, validation: validateName, disabled: settings.loading, ariaLabel: "Full name input field" })), userFields.show_email_field && (_jsx(EditableField, { label: "Email Address", value: settings.email, type: "email", placeholder: "Enter your email address", onSave: settings.handleEmailSave, validation: validateEmail, disabled: settings.loading, ariaLabel: "Email address input field" }))] })] }), userFields.show_password_field && (_jsxs("div", { className: "cls_my_settings_layout_password_section bg-white rounded-lg border border-slate-200 p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-slate-900 mb-4", children: passwordLabel }), _jsxs("div", { className: "cls_my_settings_layout_password_fields flex flex-col gap-6", children: [_jsx(FormFieldWrapper, { fieldId: "current-password", label: currentPasswordLabel, input: _jsx(PasswordField, { inputId: "current-password", ariaLabel: currentPasswordLabel, value: ((_a = settings.passwordFields) === null || _a === void 0 ? void 0 : _a.currentPassword) || "", placeholder: "Enter your current password", autoComplete: "current-password", isVisible: ((_b = settings.passwordFields) === null || _b === void 0 ? void 0 : _b.currentPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("currentPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("currentPassword"), errorMessage: (_d = (_c = settings.passwordFields) === null || _c === void 0 ? void 0 : _c.errors) === null || _d === void 0 ? void 0 : _d.currentPassword }) }), _jsxs("div", { className: "cls_my_settings_layout_password_fields_row grid grid-cols-1 md:grid-cols-2 gap-6", children: [_jsx(FormFieldWrapper, { fieldId: "new-password", label: newPasswordLabel, input: _jsx(PasswordField, { inputId: "new-password", ariaLabel: newPasswordLabel, value: ((_e = settings.passwordFields) === null || _e === void 0 ? void 0 : _e.newPassword) || "", placeholder: "Enter your new password", autoComplete: "new-password", isVisible: ((_f = settings.passwordFields) === null || _f === void 0 ? void 0 : _f.newPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("newPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("newPassword"), errorMessage: (_h = (_g = settings.passwordFields) === null || _g === void 0 ? void 0 : _g.errors) === null || _h === void 0 ? void 0 : _h.newPassword }) }), _jsx(FormFieldWrapper, { fieldId: "confirm-password", label: confirmPasswordLabel, input: _jsx(PasswordField, { inputId: "confirm-password", ariaLabel: confirmPasswordLabel, value: ((_j = settings.passwordFields) === null || _j === void 0 ? void 0 : _j.confirmPassword) || "", placeholder: "Confirm your new password", autoComplete: "new-password", isVisible: ((_k = settings.passwordFields) === null || _k === void 0 ? void 0 : _k.confirmPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("confirmPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("confirmPassword"), errorMessage: (_m = (_l = settings.passwordFields) === null || _l === void 0 ? void 0 : _l.errors) === null || _m === void 0 ? void 0 : _m.confirmPassword }) })] })] }), _jsx("div", { className: "cls_my_settings_layout_password_actions flex justify-end mt-4", children: _jsx(Button, { type: "button", onClick: settings.handlePasswordSave, disabled: settings.loading || settings.isPasswordSaveDisabled, className: "cls_my_settings_layout_save_password_button", style: {
|
|
32
|
+
backgroundColor: resolvedButtonPalette.submitBackground,
|
|
33
|
+
color: resolvedButtonPalette.submitText,
|
|
34
|
+
}, "aria-label": "Save password", children: "Save Password" }) })] })), _jsx(ProfilePictureDialog, { open: settings.profilePictureDialogOpen, onOpenChange: (open) => {
|
|
35
|
+
if (open) {
|
|
36
|
+
settings.handleProfilePictureEdit();
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
settings.handleProfilePictureDialogClose();
|
|
40
|
+
}
|
|
41
|
+
}, onSave: settings.handleProfilePictureSave, email: settings.email, allowPhotoUpload: profilePicture.allow_photo_upload, maxPhotoSize: profilePicture.max_photo_size, libraryPhotoPath: profilePicture.library_photo_path, currentProfilePictureUrl: settings.profilePictureUrl, currentProfileSource: settings.profileSource, disabled: settings.loading, messages: messages, uiSizes: uiSizes, fileTypes: fileTypes })] }) }));
|
|
42
|
+
}
|
|
43
|
+
// section: validation_helpers
|
|
44
|
+
/**
|
|
45
|
+
* Validates name (optional, but if provided should not be empty)
|
|
46
|
+
*/
|
|
47
|
+
function validateName(name) {
|
|
48
|
+
if (name.trim() === "") {
|
|
49
|
+
return "Name cannot be empty";
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Validates email format
|
|
55
|
+
*/
|
|
56
|
+
function validateEmail(email) {
|
|
57
|
+
if (!email || email.trim() === "") {
|
|
58
|
+
return "Email is required";
|
|
59
|
+
}
|
|
60
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
61
|
+
if (!emailRegex.test(email)) {
|
|
62
|
+
return "Invalid email address format";
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LayoutFieldMap, LayoutFieldMapOverrides } from "hazo_auth/components/layouts/shared/config/layout_customization";
|
|
2
|
+
import { type ButtonPaletteDefaults, type ButtonPaletteOverrides, type LayoutLabelDefaults, type LayoutLabelOverrides, type PasswordRequirementOptions, type PasswordRequirementOverrides } from "hazo_auth/components/layouts/shared/config/layout_customization";
|
|
3
|
+
export declare const REGISTER_FIELD_IDS: {
|
|
4
|
+
readonly NAME: "name";
|
|
5
|
+
readonly EMAIL: "email_address";
|
|
6
|
+
readonly PASSWORD: "password";
|
|
7
|
+
readonly CONFIRM_PASSWORD: "confirm_password";
|
|
8
|
+
};
|
|
9
|
+
export type RegisterFieldId = (typeof REGISTER_FIELD_IDS)[keyof typeof REGISTER_FIELD_IDS];
|
|
10
|
+
export declare const createRegisterFieldDefinitions: (overrides?: LayoutFieldMapOverrides) => LayoutFieldMap;
|
|
11
|
+
export declare const resolveRegisterLabels: (overrides?: LayoutLabelOverrides) => LayoutLabelDefaults;
|
|
12
|
+
export declare const resolveRegisterButtonPalette: (overrides?: ButtonPaletteOverrides) => ButtonPaletteDefaults;
|
|
13
|
+
export declare const resolveRegisterPasswordRequirements: (overrides?: PasswordRequirementOverrides) => PasswordRequirementOptions;
|
|
14
|
+
//# sourceMappingURL=register_field_config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register_field_config.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/register/config/register_field_config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,iEAAiE,CAAC;AAC/H,OAAO,EAKL,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EAClC,MAAM,iEAAiE,CAAC;AAGzE,eAAO,MAAM,kBAAkB;;;;;CAKrB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAsC3F,eAAO,MAAM,8BAA8B,GACzC,YAAY,uBAAuB,mBAC8B,CAAC;AAUpE,eAAO,MAAM,qBAAqB,GAAI,YAAY,oBAAoB,wBACnB,CAAC;AAUpD,eAAO,MAAM,4BAA4B,GAAI,YAAY,sBAAsB,0BACZ,CAAC;AAWpE,eAAO,MAAM,mCAAmC,GAC9C,YAAY,4BAA4B,+BACiC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { resolveButtonPalette, resolveFieldDefinitions, resolveLabels, resolvePasswordRequirements, } from "hazo_auth/components/layouts/shared/config/layout_customization";
|
|
2
|
+
// section: field_identifiers
|
|
3
|
+
export const REGISTER_FIELD_IDS = {
|
|
4
|
+
NAME: "name",
|
|
5
|
+
EMAIL: "email_address",
|
|
6
|
+
PASSWORD: "password",
|
|
7
|
+
CONFIRM_PASSWORD: "confirm_password",
|
|
8
|
+
};
|
|
9
|
+
// section: field_definitions
|
|
10
|
+
const REGISTER_FIELD_DEFINITIONS = {
|
|
11
|
+
[REGISTER_FIELD_IDS.NAME]: {
|
|
12
|
+
id: REGISTER_FIELD_IDS.NAME,
|
|
13
|
+
label: "Full name",
|
|
14
|
+
type: "text",
|
|
15
|
+
autoComplete: "name",
|
|
16
|
+
placeholder: "Enter your full name",
|
|
17
|
+
ariaLabel: "Full name input field",
|
|
18
|
+
},
|
|
19
|
+
[REGISTER_FIELD_IDS.EMAIL]: {
|
|
20
|
+
id: REGISTER_FIELD_IDS.EMAIL,
|
|
21
|
+
label: "Email address",
|
|
22
|
+
type: "email",
|
|
23
|
+
autoComplete: "email",
|
|
24
|
+
placeholder: "Enter your email address",
|
|
25
|
+
ariaLabel: "Email address input field",
|
|
26
|
+
},
|
|
27
|
+
[REGISTER_FIELD_IDS.PASSWORD]: {
|
|
28
|
+
id: REGISTER_FIELD_IDS.PASSWORD,
|
|
29
|
+
label: "Password",
|
|
30
|
+
type: "password",
|
|
31
|
+
autoComplete: "new-password",
|
|
32
|
+
placeholder: "Enter your password",
|
|
33
|
+
ariaLabel: "Password input field",
|
|
34
|
+
},
|
|
35
|
+
[REGISTER_FIELD_IDS.CONFIRM_PASSWORD]: {
|
|
36
|
+
id: REGISTER_FIELD_IDS.CONFIRM_PASSWORD,
|
|
37
|
+
label: "Re-enter password",
|
|
38
|
+
type: "password",
|
|
39
|
+
autoComplete: "new-password",
|
|
40
|
+
placeholder: "Re-enter your password",
|
|
41
|
+
ariaLabel: "Re-enter password input field",
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
export const createRegisterFieldDefinitions = (overrides) => resolveFieldDefinitions(REGISTER_FIELD_DEFINITIONS, overrides);
|
|
45
|
+
// section: label_defaults
|
|
46
|
+
const REGISTER_LABEL_DEFAULTS = {
|
|
47
|
+
heading: "Create your hazo account",
|
|
48
|
+
subHeading: "Secure your access with editable fields powered by shadcn components.",
|
|
49
|
+
submitButton: "Register",
|
|
50
|
+
cancelButton: "Cancel",
|
|
51
|
+
};
|
|
52
|
+
export const resolveRegisterLabels = (overrides) => resolveLabels(REGISTER_LABEL_DEFAULTS, overrides);
|
|
53
|
+
// section: button_palette_defaults
|
|
54
|
+
const REGISTER_BUTTON_PALETTE_DEFAULTS = {
|
|
55
|
+
submitBackground: "#0f172a",
|
|
56
|
+
submitText: "#ffffff",
|
|
57
|
+
cancelBorder: "#cbd5f5",
|
|
58
|
+
cancelText: "#0f172a",
|
|
59
|
+
};
|
|
60
|
+
export const resolveRegisterButtonPalette = (overrides) => resolveButtonPalette(REGISTER_BUTTON_PALETTE_DEFAULTS, overrides);
|
|
61
|
+
// section: password_rules
|
|
62
|
+
const REGISTER_PASSWORD_REQUIREMENTS = {
|
|
63
|
+
minimum_length: 8,
|
|
64
|
+
require_uppercase: true,
|
|
65
|
+
require_lowercase: true,
|
|
66
|
+
require_number: true,
|
|
67
|
+
require_special: true,
|
|
68
|
+
};
|
|
69
|
+
export const resolveRegisterPasswordRequirements = (overrides) => resolvePasswordRequirements(REGISTER_PASSWORD_REQUIREMENTS, overrides);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { LayoutDataClient } from "hazo_auth/components/layouts/shared/data/layout_data_client";
|
|
2
|
+
import type { PasswordRequirementOptions, PasswordRequirementOverrides } from "hazo_auth/components/layouts/shared/config/layout_customization";
|
|
3
|
+
import { type RegisterFieldId } from "hazo_auth/components/layouts/register/config/register_field_config";
|
|
4
|
+
export type RegisterFormValues = Record<RegisterFieldId, string>;
|
|
5
|
+
export type RegisterFormErrors = Partial<Record<RegisterFieldId, string | string[]>> & {
|
|
6
|
+
submit?: string;
|
|
7
|
+
};
|
|
8
|
+
export type PasswordVisibilityState = Record<Extract<RegisterFieldId, "password" | "confirm_password">, boolean>;
|
|
9
|
+
export type UseRegisterFormParams<TClient = unknown> = {
|
|
10
|
+
showNameField: boolean;
|
|
11
|
+
passwordRequirements: PasswordRequirementOptions;
|
|
12
|
+
passwordRequirementOverrides?: PasswordRequirementOverrides;
|
|
13
|
+
dataClient: LayoutDataClient<TClient>;
|
|
14
|
+
urlOnLogon?: string;
|
|
15
|
+
};
|
|
16
|
+
export type UseRegisterFormResult = {
|
|
17
|
+
values: RegisterFormValues;
|
|
18
|
+
errors: RegisterFormErrors;
|
|
19
|
+
passwordVisibility: PasswordVisibilityState;
|
|
20
|
+
isSubmitDisabled: boolean;
|
|
21
|
+
isSubmitting: boolean;
|
|
22
|
+
emailTouched: boolean;
|
|
23
|
+
handleFieldChange: (fieldId: RegisterFieldId, value: string) => void;
|
|
24
|
+
handleEmailBlur: () => void;
|
|
25
|
+
togglePasswordVisibility: (fieldId: "password" | "confirm_password") => void;
|
|
26
|
+
handleSubmit: (event: React.FormEvent<HTMLFormElement>) => void;
|
|
27
|
+
handleCancel: () => void;
|
|
28
|
+
};
|
|
29
|
+
export declare const use_register_form: <TClient>({ showNameField, passwordRequirements, dataClient, urlOnLogon, }: UseRegisterFormParams<TClient>) => UseRegisterFormResult;
|
|
30
|
+
//# sourceMappingURL=use_register_form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use_register_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/register/hooks/use_register_form.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6DAA6D,CAAC;AACpG,OAAO,KAAK,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,iEAAiE,CAAC;AAChJ,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,oEAAoE,CAAC;AAU9H,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AACjE,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,GAAG;IACrF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C,OAAO,CAAC,eAAe,EAAE,UAAU,GAAG,kBAAkB,CAAC,EACzD,OAAO,CACR,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,OAAO,GAAG,OAAO,IAAI;IACrD,aAAa,EAAE,OAAO,CAAC;IACvB,oBAAoB,EAAE,0BAA0B,CAAC;IACjD,4BAA4B,CAAC,EAAE,4BAA4B,CAAC;IAC5D,UAAU,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,kBAAkB,EAAE,uBAAuB,CAAC;IAC5C,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,wBAAwB,EAAE,CAAC,OAAO,EAAE,UAAU,GAAG,kBAAkB,KAAK,IAAI,CAAC;IAC7E,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;IAChE,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B,CAAC;AAYF,eAAO,MAAM,iBAAiB,GAAI,OAAO,EAAG,kEAKzC,qBAAqB,CAAC,OAAO,CAAC,KAAG,qBAmNnC,CAAC"}
|