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,318 @@
|
|
|
1
|
+
import { createCrudService } from "hazo_connect/server";
|
|
2
|
+
import { create_token } from "hazo_auth/lib/services/token_service";
|
|
3
|
+
import argon2 from "argon2";
|
|
4
|
+
import { create_app_logger } from "hazo_auth/lib/app_logger";
|
|
5
|
+
import { send_template_email } from "hazo_auth/lib/services/email_service";
|
|
6
|
+
// section: helpers
|
|
7
|
+
/**
|
|
8
|
+
* Requests a password reset for a user by email
|
|
9
|
+
* Generates a secure token, hashes it, and stores it in hazo_refresh_tokens with token_type = 'password_reset'
|
|
10
|
+
* Invalidates any existing password reset tokens for the user before creating a new one
|
|
11
|
+
* @param adapter - The hazo_connect adapter instance
|
|
12
|
+
* @param data - Password reset request data (email)
|
|
13
|
+
* @returns Password reset request result with success status or error
|
|
14
|
+
*/
|
|
15
|
+
export async function request_password_reset(adapter, data) {
|
|
16
|
+
try {
|
|
17
|
+
const { email } = data;
|
|
18
|
+
// Create CRUD service for hazo_users table
|
|
19
|
+
const users_service = createCrudService(adapter, "hazo_users");
|
|
20
|
+
// Find user by email
|
|
21
|
+
const users = await users_service.findBy({
|
|
22
|
+
email_address: email,
|
|
23
|
+
});
|
|
24
|
+
// If user not found, return success anyway (to prevent email enumeration)
|
|
25
|
+
if (!Array.isArray(users) || users.length === 0) {
|
|
26
|
+
return {
|
|
27
|
+
success: true,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const user = users[0];
|
|
31
|
+
const user_id = user.id;
|
|
32
|
+
// Create password reset token using shared token service
|
|
33
|
+
const token_result = await create_token({
|
|
34
|
+
adapter,
|
|
35
|
+
user_id,
|
|
36
|
+
token_type: "password_reset",
|
|
37
|
+
});
|
|
38
|
+
if (!token_result.success) {
|
|
39
|
+
return {
|
|
40
|
+
success: false,
|
|
41
|
+
error: token_result.error || "Failed to create password reset token",
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
// Send password reset email if token was created successfully
|
|
45
|
+
if (token_result.raw_token) {
|
|
46
|
+
const email_result = await send_template_email("forgot_password", email, {
|
|
47
|
+
token: token_result.raw_token,
|
|
48
|
+
user_email: email,
|
|
49
|
+
user_name: user.name,
|
|
50
|
+
});
|
|
51
|
+
if (!email_result.success) {
|
|
52
|
+
const logger = create_app_logger();
|
|
53
|
+
logger.error("password_reset_service_email_send_failed", {
|
|
54
|
+
filename: "password_reset_service.ts",
|
|
55
|
+
line_number: 0,
|
|
56
|
+
user_id,
|
|
57
|
+
email,
|
|
58
|
+
error: email_result.error,
|
|
59
|
+
note: "Password reset token created but email failed to send",
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
success: true,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
const error_message = error instanceof Error ? error.message : "Unknown error";
|
|
69
|
+
return {
|
|
70
|
+
success: false,
|
|
71
|
+
error: error_message,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Validates a password reset token without resetting the password
|
|
77
|
+
* Verifies the token exists and checks if it has expired
|
|
78
|
+
* @param adapter - The hazo_connect adapter instance
|
|
79
|
+
* @param data - Token validation data (token)
|
|
80
|
+
* @returns Token validation result with success status or error
|
|
81
|
+
*/
|
|
82
|
+
export async function validate_password_reset_token(adapter, data) {
|
|
83
|
+
try {
|
|
84
|
+
const { token } = data;
|
|
85
|
+
// Create CRUD service for hazo_refresh_tokens table
|
|
86
|
+
const tokens_service = createCrudService(adapter, "hazo_refresh_tokens");
|
|
87
|
+
// Find all password reset tokens
|
|
88
|
+
// If token_type column doesn't exist, query all tokens and filter manually
|
|
89
|
+
let all_tokens = [];
|
|
90
|
+
try {
|
|
91
|
+
all_tokens = (await tokens_service.findBy({
|
|
92
|
+
token_type: "password_reset",
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
// If token_type column doesn't exist, get all tokens and we'll verify each one
|
|
97
|
+
const logger = create_app_logger();
|
|
98
|
+
const error_message = error instanceof Error ? error.message : "Unknown error";
|
|
99
|
+
logger.warn("password_reset_service_token_type_column_missing", {
|
|
100
|
+
filename: "password_reset_service.ts",
|
|
101
|
+
line_number: 0,
|
|
102
|
+
error: error_message,
|
|
103
|
+
note: "token_type column may not exist, querying all tokens",
|
|
104
|
+
});
|
|
105
|
+
try {
|
|
106
|
+
// Query all tokens (will need to verify each one)
|
|
107
|
+
all_tokens = (await tokens_service.findBy({}));
|
|
108
|
+
}
|
|
109
|
+
catch (fallbackError) {
|
|
110
|
+
const fallback_error_message = fallbackError instanceof Error ? fallbackError.message : "Unknown error";
|
|
111
|
+
logger.error("password_reset_service_query_tokens_failed", {
|
|
112
|
+
filename: "password_reset_service.ts",
|
|
113
|
+
line_number: 0,
|
|
114
|
+
error: fallback_error_message,
|
|
115
|
+
});
|
|
116
|
+
return {
|
|
117
|
+
success: false,
|
|
118
|
+
error: "Invalid or expired reset token",
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (!Array.isArray(all_tokens) || all_tokens.length === 0) {
|
|
123
|
+
return {
|
|
124
|
+
success: false,
|
|
125
|
+
error: "Invalid or expired reset token",
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
// Find the matching token by verifying the hash
|
|
129
|
+
let matching_token = null;
|
|
130
|
+
for (const stored_token of all_tokens) {
|
|
131
|
+
try {
|
|
132
|
+
const token_hash = stored_token.token_hash;
|
|
133
|
+
const is_valid = await argon2.verify(token_hash, token);
|
|
134
|
+
if (is_valid) {
|
|
135
|
+
matching_token = stored_token;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
catch (_a) {
|
|
140
|
+
// Continue to next token if verification fails
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (!matching_token) {
|
|
145
|
+
return {
|
|
146
|
+
success: false,
|
|
147
|
+
error: "Invalid or expired reset token",
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
// Check if token has expired
|
|
151
|
+
const expires_at = new Date(matching_token.expires_at);
|
|
152
|
+
const now = new Date();
|
|
153
|
+
if (expires_at < now) {
|
|
154
|
+
return {
|
|
155
|
+
success: false,
|
|
156
|
+
error: "Reset token has expired",
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
success: true,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
const error_message = error instanceof Error ? error.message : "Unknown error";
|
|
165
|
+
return {
|
|
166
|
+
success: false,
|
|
167
|
+
error: error_message,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Resets a user's password using a password reset token
|
|
173
|
+
* Verifies the token, checks expiration, updates password, and deletes the token
|
|
174
|
+
* @param adapter - The hazo_connect adapter instance
|
|
175
|
+
* @param data - Password reset data (token, new_password)
|
|
176
|
+
* @returns Password reset result with success status, user_id, email, or error
|
|
177
|
+
*/
|
|
178
|
+
export async function reset_password(adapter, data) {
|
|
179
|
+
try {
|
|
180
|
+
const { token, new_password, minimum_length = 8 } = data;
|
|
181
|
+
// Validate password
|
|
182
|
+
if (!new_password || new_password.length < minimum_length) {
|
|
183
|
+
return {
|
|
184
|
+
success: false,
|
|
185
|
+
error: `Password must be at least ${minimum_length} character${minimum_length === 1 ? "" : "s"} long`,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
// Create CRUD service for hazo_refresh_tokens table
|
|
189
|
+
const tokens_service = createCrudService(adapter, "hazo_refresh_tokens");
|
|
190
|
+
// Find all password reset tokens
|
|
191
|
+
// If token_type column doesn't exist, query all tokens and filter manually
|
|
192
|
+
let all_tokens = [];
|
|
193
|
+
try {
|
|
194
|
+
all_tokens = (await tokens_service.findBy({
|
|
195
|
+
token_type: "password_reset",
|
|
196
|
+
}));
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
// If token_type column doesn't exist, get all tokens and we'll verify each one
|
|
200
|
+
const logger = create_app_logger();
|
|
201
|
+
const error_message = error instanceof Error ? error.message : "Unknown error";
|
|
202
|
+
logger.warn("password_reset_service_token_type_column_missing", {
|
|
203
|
+
filename: "password_reset_service.ts",
|
|
204
|
+
line_number: 0,
|
|
205
|
+
error: error_message,
|
|
206
|
+
note: "token_type column may not exist, querying all tokens",
|
|
207
|
+
});
|
|
208
|
+
try {
|
|
209
|
+
// Query all tokens (will need to verify each one)
|
|
210
|
+
all_tokens = (await tokens_service.findBy({}));
|
|
211
|
+
}
|
|
212
|
+
catch (fallbackError) {
|
|
213
|
+
const fallback_error_message = fallbackError instanceof Error ? fallbackError.message : "Unknown error";
|
|
214
|
+
logger.error("password_reset_service_query_tokens_failed", {
|
|
215
|
+
filename: "password_reset_service.ts",
|
|
216
|
+
line_number: 0,
|
|
217
|
+
error: fallback_error_message,
|
|
218
|
+
});
|
|
219
|
+
return {
|
|
220
|
+
success: false,
|
|
221
|
+
error: "Invalid or expired reset token",
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (!Array.isArray(all_tokens) || all_tokens.length === 0) {
|
|
226
|
+
return {
|
|
227
|
+
success: false,
|
|
228
|
+
error: "Invalid or expired reset token",
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
// Find the matching token by verifying the hash
|
|
232
|
+
let matching_token = null;
|
|
233
|
+
let user_id = null;
|
|
234
|
+
for (const stored_token of all_tokens) {
|
|
235
|
+
try {
|
|
236
|
+
const token_hash = stored_token.token_hash;
|
|
237
|
+
const is_valid = await argon2.verify(token_hash, token);
|
|
238
|
+
if (is_valid) {
|
|
239
|
+
matching_token = stored_token;
|
|
240
|
+
user_id = stored_token.user_id;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
catch (_a) {
|
|
245
|
+
// Continue to next token if verification fails
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (!matching_token || !user_id) {
|
|
250
|
+
return {
|
|
251
|
+
success: false,
|
|
252
|
+
error: "Invalid or expired reset token",
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
// Check if token has expired
|
|
256
|
+
const expires_at = new Date(matching_token.expires_at);
|
|
257
|
+
const now = new Date();
|
|
258
|
+
if (expires_at < now) {
|
|
259
|
+
// Delete expired token
|
|
260
|
+
await tokens_service.deleteById(matching_token.id);
|
|
261
|
+
return {
|
|
262
|
+
success: false,
|
|
263
|
+
error: "Reset token has expired",
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
// Get user email before updating
|
|
267
|
+
const users_service = createCrudService(adapter, "hazo_users");
|
|
268
|
+
const users = await users_service.findBy({
|
|
269
|
+
id: user_id,
|
|
270
|
+
});
|
|
271
|
+
if (!Array.isArray(users) || users.length === 0) {
|
|
272
|
+
return {
|
|
273
|
+
success: false,
|
|
274
|
+
error: "User not found",
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
const user = users[0];
|
|
278
|
+
const email = user.email_address;
|
|
279
|
+
// Hash the new password
|
|
280
|
+
const password_hash = await argon2.hash(new_password);
|
|
281
|
+
// Update user's password
|
|
282
|
+
const now_iso = new Date().toISOString();
|
|
283
|
+
await users_service.updateById(user_id, {
|
|
284
|
+
password_hash: password_hash,
|
|
285
|
+
changed_at: now_iso,
|
|
286
|
+
});
|
|
287
|
+
// Delete the used token
|
|
288
|
+
await tokens_service.deleteById(matching_token.id);
|
|
289
|
+
// Send password changed notification email
|
|
290
|
+
const email_result = await send_template_email("password_changed", email, {
|
|
291
|
+
user_email: email,
|
|
292
|
+
user_name: user.name,
|
|
293
|
+
});
|
|
294
|
+
if (!email_result.success) {
|
|
295
|
+
const logger = create_app_logger();
|
|
296
|
+
logger.error("password_reset_service_password_changed_email_failed", {
|
|
297
|
+
filename: "password_reset_service.ts",
|
|
298
|
+
line_number: 0,
|
|
299
|
+
user_id,
|
|
300
|
+
email,
|
|
301
|
+
error: email_result.error,
|
|
302
|
+
note: "Password was reset successfully but notification email failed to send",
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
return {
|
|
306
|
+
success: true,
|
|
307
|
+
user_id,
|
|
308
|
+
email,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
catch (error) {
|
|
312
|
+
const error_message = error instanceof Error ? error.message : "Unknown error";
|
|
313
|
+
return {
|
|
314
|
+
success: false,
|
|
315
|
+
error: error_message,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HazoConnectAdapter } from "hazo_connect";
|
|
2
|
+
export type RemoveProfilePictureResult = {
|
|
3
|
+
success: boolean;
|
|
4
|
+
error?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Removes user profile picture
|
|
8
|
+
* - If source is "upload": deletes the uploaded file and clears profile_picture_url and profile_source
|
|
9
|
+
* - If source is "gravatar" or "library": clears profile_picture_url and profile_source
|
|
10
|
+
* @param adapter - The hazo_connect adapter instance
|
|
11
|
+
* @param user_id - User ID
|
|
12
|
+
* @returns Remove result with success status or error
|
|
13
|
+
*/
|
|
14
|
+
export declare function remove_user_profile_picture(adapter: HazoConnectAdapter, user_id: string): Promise<RemoveProfilePictureResult>;
|
|
15
|
+
//# sourceMappingURL=profile_picture_remove_service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile_picture_remove_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/profile_picture_remove_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AASvD,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF;;;;;;;GAOG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,0BAA0B,CAAC,CA0FrC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { createCrudService } from "hazo_connect/server";
|
|
2
|
+
import { map_db_source_to_ui } from "hazo_auth/lib/services/profile_picture_source_mapper";
|
|
3
|
+
import { get_profile_picture_config } from "hazo_auth/lib/profile_picture_config.server";
|
|
4
|
+
import { create_app_logger } from "hazo_auth/lib/app_logger";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
// section: helpers
|
|
8
|
+
/**
|
|
9
|
+
* Removes user profile picture
|
|
10
|
+
* - If source is "upload": deletes the uploaded file and clears profile_picture_url and profile_source
|
|
11
|
+
* - If source is "gravatar" or "library": clears profile_picture_url and profile_source
|
|
12
|
+
* @param adapter - The hazo_connect adapter instance
|
|
13
|
+
* @param user_id - User ID
|
|
14
|
+
* @returns Remove result with success status or error
|
|
15
|
+
*/
|
|
16
|
+
export async function remove_user_profile_picture(adapter, user_id) {
|
|
17
|
+
try {
|
|
18
|
+
const users_service = createCrudService(adapter, "hazo_users");
|
|
19
|
+
// Get current user data
|
|
20
|
+
const users = await users_service.findBy({
|
|
21
|
+
id: user_id,
|
|
22
|
+
});
|
|
23
|
+
if (!Array.isArray(users) || users.length === 0) {
|
|
24
|
+
return {
|
|
25
|
+
success: false,
|
|
26
|
+
error: "User not found",
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const current_user = users[0];
|
|
30
|
+
const profile_picture_url = current_user.profile_picture_url || null;
|
|
31
|
+
const profile_source_db = current_user.profile_source || null;
|
|
32
|
+
if (!profile_picture_url || !profile_source_db) {
|
|
33
|
+
// No profile picture to remove
|
|
34
|
+
return {
|
|
35
|
+
success: true,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// Map database source to UI source
|
|
39
|
+
const profile_source_ui = map_db_source_to_ui(profile_source_db);
|
|
40
|
+
// If source is "upload", delete the file
|
|
41
|
+
if (profile_source_ui === "upload") {
|
|
42
|
+
try {
|
|
43
|
+
const config = get_profile_picture_config();
|
|
44
|
+
if (config.upload_photo_path) {
|
|
45
|
+
// Extract filename from URL (e.g., /api/hazo_auth/profile_picture/user_id.jpg)
|
|
46
|
+
const fileName = profile_picture_url.split("/").pop();
|
|
47
|
+
if (fileName && fileName.startsWith(user_id)) {
|
|
48
|
+
// Resolve upload path
|
|
49
|
+
const uploadPath = path.isAbsolute(config.upload_photo_path)
|
|
50
|
+
? config.upload_photo_path
|
|
51
|
+
: path.resolve(process.cwd(), config.upload_photo_path);
|
|
52
|
+
const filePath = path.join(uploadPath, fileName);
|
|
53
|
+
// Delete file if it exists
|
|
54
|
+
if (fs.existsSync(filePath)) {
|
|
55
|
+
fs.unlinkSync(filePath);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
// Log error but continue with database update
|
|
62
|
+
const logger = create_app_logger();
|
|
63
|
+
const error_message = error instanceof Error ? error.message : "Unknown error";
|
|
64
|
+
logger.warn("profile_picture_remove_file_delete_failed", {
|
|
65
|
+
filename: "profile_picture_remove_service.ts",
|
|
66
|
+
line_number: 0,
|
|
67
|
+
user_id,
|
|
68
|
+
profile_picture_url,
|
|
69
|
+
error: error_message,
|
|
70
|
+
});
|
|
71
|
+
// Don't fail the request if file deletion fails - still clear the database
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Clear profile picture URL and source in database
|
|
75
|
+
// Note: profile_source has a CHECK constraint, so we'll set it to null
|
|
76
|
+
// If the database doesn't allow null, we may need to handle it differently
|
|
77
|
+
const update_data = {
|
|
78
|
+
changed_at: new Date().toISOString(),
|
|
79
|
+
profile_picture_url: null,
|
|
80
|
+
profile_source: null,
|
|
81
|
+
};
|
|
82
|
+
await users_service.updateById(user_id, update_data);
|
|
83
|
+
return {
|
|
84
|
+
success: true,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
const error_message = error instanceof Error ? error.message : "Unknown error";
|
|
89
|
+
return {
|
|
90
|
+
success: false,
|
|
91
|
+
error: error_message,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { HazoConnectAdapter } from "hazo_connect";
|
|
2
|
+
import { type ProfilePictureSourceUI } from "hazo_auth/lib/services/profile_picture_source_mapper";
|
|
3
|
+
export type ProfilePictureSource = ProfilePictureSourceUI;
|
|
4
|
+
export type DefaultProfilePictureResult = {
|
|
5
|
+
profile_picture_url: string;
|
|
6
|
+
profile_source: ProfilePictureSource;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Generates Gravatar URL from email address
|
|
10
|
+
* @param email - User's email address
|
|
11
|
+
* @param size - Image size in pixels (defaults to config value)
|
|
12
|
+
* @returns Gravatar URL
|
|
13
|
+
*/
|
|
14
|
+
export declare function get_gravatar_url(email: string, size?: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* Gets library photo categories by reading subdirectories
|
|
17
|
+
* @returns Array of category names
|
|
18
|
+
*/
|
|
19
|
+
export declare function get_library_categories(): string[];
|
|
20
|
+
/**
|
|
21
|
+
* Gets photos in a specific library category
|
|
22
|
+
* @param category - Category name
|
|
23
|
+
* @returns Array of photo URLs (relative to public directory)
|
|
24
|
+
*/
|
|
25
|
+
export declare function get_library_photos(category: string): string[];
|
|
26
|
+
/**
|
|
27
|
+
* Gets default profile picture based on configuration priority
|
|
28
|
+
* @param user_email - User's email address
|
|
29
|
+
* @param user_name - User's name (optional)
|
|
30
|
+
* @returns Default profile picture URL and source, or null if no default available
|
|
31
|
+
*/
|
|
32
|
+
export declare function get_default_profile_picture(user_email: string, user_name?: string): DefaultProfilePictureResult | null;
|
|
33
|
+
/**
|
|
34
|
+
* Updates user profile picture in database
|
|
35
|
+
* @param adapter - The hazo_connect adapter instance
|
|
36
|
+
* @param user_id - User ID
|
|
37
|
+
* @param profile_picture_url - Profile picture URL
|
|
38
|
+
* @param profile_source - Profile picture source type
|
|
39
|
+
* @returns Success status
|
|
40
|
+
*/
|
|
41
|
+
export declare function update_user_profile_picture(adapter: HazoConnectAdapter, user_id: string, profile_picture_url: string, profile_source: ProfilePictureSource): Promise<{
|
|
42
|
+
success: boolean;
|
|
43
|
+
error?: string;
|
|
44
|
+
}>;
|
|
45
|
+
//# sourceMappingURL=profile_picture_service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile_picture_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/profile_picture_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AASvD,OAAO,EAAuB,KAAK,sBAAsB,EAAE,MAAM,sDAAsD,CAAC;AAGxH,MAAM,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAE1D,MAAM,MAAM,2BAA2B,GAAG;IACxC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,oBAAoB,CAAC;CACtC,CAAC;AAGF;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAOrE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAyBjD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAiC7D;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,2BAA2B,GAAG,IAAI,CA2DpC;AAED;;;;;;;GAOG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,EACf,mBAAmB,EAAE,MAAM,EAC3B,cAAc,EAAE,oBAAoB,GACnC,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAsB/C"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { createCrudService } from "hazo_connect/server";
|
|
2
|
+
import gravatarUrl from "gravatar-url";
|
|
3
|
+
import { get_profile_picture_config } from "hazo_auth/lib/profile_picture_config.server";
|
|
4
|
+
import { get_ui_sizes_config } from "hazo_auth/lib/ui_sizes_config.server";
|
|
5
|
+
import { get_file_types_config } from "hazo_auth/lib/file_types_config.server";
|
|
6
|
+
import { create_app_logger } from "hazo_auth/lib/app_logger";
|
|
7
|
+
import path from "path";
|
|
8
|
+
import fs from "fs";
|
|
9
|
+
import { map_ui_source_to_db } from "hazo_auth/lib/services/profile_picture_source_mapper";
|
|
10
|
+
// section: helpers
|
|
11
|
+
/**
|
|
12
|
+
* Generates Gravatar URL from email address
|
|
13
|
+
* @param email - User's email address
|
|
14
|
+
* @param size - Image size in pixels (defaults to config value)
|
|
15
|
+
* @returns Gravatar URL
|
|
16
|
+
*/
|
|
17
|
+
export function get_gravatar_url(email, size) {
|
|
18
|
+
const uiSizes = get_ui_sizes_config();
|
|
19
|
+
const gravatarSize = size || uiSizes.gravatar_size;
|
|
20
|
+
return gravatarUrl(email, {
|
|
21
|
+
size: gravatarSize,
|
|
22
|
+
default: "identicon",
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Gets library photo categories by reading subdirectories
|
|
27
|
+
* @returns Array of category names
|
|
28
|
+
*/
|
|
29
|
+
export function get_library_categories() {
|
|
30
|
+
const config = get_profile_picture_config();
|
|
31
|
+
const library_path = path.resolve(process.cwd(), "public", config.library_photo_path.replace(/^\//, ""));
|
|
32
|
+
if (!fs.existsSync(library_path)) {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const entries = fs.readdirSync(library_path, { withFileTypes: true });
|
|
37
|
+
return entries
|
|
38
|
+
.filter((entry) => entry.isDirectory())
|
|
39
|
+
.map((entry) => entry.name)
|
|
40
|
+
.sort();
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
const logger = create_app_logger();
|
|
44
|
+
const error_message = error instanceof Error ? error.message : "Unknown error";
|
|
45
|
+
logger.warn("profile_picture_service_read_categories_failed", {
|
|
46
|
+
filename: "profile_picture_service.ts",
|
|
47
|
+
line_number: 0,
|
|
48
|
+
library_path,
|
|
49
|
+
error: error_message,
|
|
50
|
+
});
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Gets photos in a specific library category
|
|
56
|
+
* @param category - Category name
|
|
57
|
+
* @returns Array of photo URLs (relative to public directory)
|
|
58
|
+
*/
|
|
59
|
+
export function get_library_photos(category) {
|
|
60
|
+
const config = get_profile_picture_config();
|
|
61
|
+
const category_path = path.resolve(process.cwd(), "public", config.library_photo_path.replace(/^\//, ""), category);
|
|
62
|
+
if (!fs.existsSync(category_path)) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
const fileTypes = get_file_types_config();
|
|
67
|
+
const allowedExtensions = fileTypes.allowed_image_extensions.map(ext => `.${ext.toLowerCase()}`);
|
|
68
|
+
const entries = fs.readdirSync(category_path, { withFileTypes: true });
|
|
69
|
+
const photos = entries
|
|
70
|
+
.filter((entry) => {
|
|
71
|
+
if (!entry.isFile())
|
|
72
|
+
return false;
|
|
73
|
+
const ext = path.extname(entry.name).toLowerCase();
|
|
74
|
+
return allowedExtensions.includes(ext);
|
|
75
|
+
})
|
|
76
|
+
.map((entry) => `${config.library_photo_path}/${category}/${entry.name}`)
|
|
77
|
+
.sort();
|
|
78
|
+
return photos;
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
const logger = create_app_logger();
|
|
82
|
+
const error_message = error instanceof Error ? error.message : "Unknown error";
|
|
83
|
+
logger.warn("profile_picture_service_read_photos_failed", {
|
|
84
|
+
filename: "profile_picture_service.ts",
|
|
85
|
+
line_number: 0,
|
|
86
|
+
category,
|
|
87
|
+
category_path,
|
|
88
|
+
error: error_message,
|
|
89
|
+
});
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Gets default profile picture based on configuration priority
|
|
95
|
+
* @param user_email - User's email address
|
|
96
|
+
* @param user_name - User's name (optional)
|
|
97
|
+
* @returns Default profile picture URL and source, or null if no default available
|
|
98
|
+
*/
|
|
99
|
+
export function get_default_profile_picture(user_email, user_name) {
|
|
100
|
+
const config = get_profile_picture_config();
|
|
101
|
+
if (!config.user_photo_default) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const uiSizes = get_ui_sizes_config();
|
|
105
|
+
// Try priority 1
|
|
106
|
+
if (config.user_photo_default_priority1 === "gravatar") {
|
|
107
|
+
const gravatar_url = get_gravatar_url(user_email, uiSizes.gravatar_size);
|
|
108
|
+
// Note: We can't check if Gravatar actually exists without making a request
|
|
109
|
+
// For now, we'll always return Gravatar URL and let the browser handle 404
|
|
110
|
+
return {
|
|
111
|
+
profile_picture_url: gravatar_url,
|
|
112
|
+
profile_source: "gravatar",
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
else if (config.user_photo_default_priority1 === "library") {
|
|
116
|
+
const categories = get_library_categories();
|
|
117
|
+
if (categories.length > 0) {
|
|
118
|
+
// Use first category, first photo as default
|
|
119
|
+
const photos = get_library_photos(categories[0]);
|
|
120
|
+
if (photos.length > 0) {
|
|
121
|
+
return {
|
|
122
|
+
profile_picture_url: photos[0],
|
|
123
|
+
profile_source: "library",
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Try priority 2 if priority 1 didn't work (only if priority2 is different from priority1)
|
|
129
|
+
const priority1 = config.user_photo_default_priority1;
|
|
130
|
+
const priority2 = config.user_photo_default_priority2;
|
|
131
|
+
if (priority2 && priority2 !== priority1) {
|
|
132
|
+
if (priority2 === "gravatar") {
|
|
133
|
+
const gravatar_url = get_gravatar_url(user_email, uiSizes.gravatar_size);
|
|
134
|
+
return {
|
|
135
|
+
profile_picture_url: gravatar_url,
|
|
136
|
+
profile_source: "gravatar",
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
else if (priority2 === "library") {
|
|
140
|
+
const categories = get_library_categories();
|
|
141
|
+
if (categories.length > 0) {
|
|
142
|
+
const photos = get_library_photos(categories[0]);
|
|
143
|
+
if (photos.length > 0) {
|
|
144
|
+
return {
|
|
145
|
+
profile_picture_url: photos[0],
|
|
146
|
+
profile_source: "library",
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// No default photo available
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Updates user profile picture in database
|
|
157
|
+
* @param adapter - The hazo_connect adapter instance
|
|
158
|
+
* @param user_id - User ID
|
|
159
|
+
* @param profile_picture_url - Profile picture URL
|
|
160
|
+
* @param profile_source - Profile picture source type
|
|
161
|
+
* @returns Success status
|
|
162
|
+
*/
|
|
163
|
+
export async function update_user_profile_picture(adapter, user_id, profile_picture_url, profile_source) {
|
|
164
|
+
try {
|
|
165
|
+
const users_service = createCrudService(adapter, "hazo_users");
|
|
166
|
+
const now = new Date().toISOString();
|
|
167
|
+
// Map UI source value to database enum value
|
|
168
|
+
const db_profile_source = map_ui_source_to_db(profile_source);
|
|
169
|
+
await users_service.updateById(user_id, {
|
|
170
|
+
profile_picture_url,
|
|
171
|
+
profile_source: db_profile_source,
|
|
172
|
+
changed_at: now,
|
|
173
|
+
});
|
|
174
|
+
return { success: true };
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
const error_message = error instanceof Error ? error.message : "Unknown error";
|
|
178
|
+
return {
|
|
179
|
+
success: false,
|
|
180
|
+
error: error_message,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|