hazo_auth 1.4.1 → 1.6.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 +25 -38
- package/SETUP_CHECKLIST.md +708 -0
- package/dist/app/api/hazo_auth/change_password/route.d.ts +8 -0
- package/dist/app/api/hazo_auth/change_password/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/change_password/route.js +98 -0
- package/dist/app/api/hazo_auth/forgot_password/route.d.ts +8 -0
- package/dist/app/api/hazo_auth/forgot_password/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/forgot_password/route.js +78 -0
- package/dist/app/api/hazo_auth/get_auth/route.d.ts +10 -0
- package/dist/app/api/hazo_auth/get_auth/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/get_auth/route.js +63 -0
- package/dist/app/api/hazo_auth/invalidate_cache/route.d.ts +14 -0
- package/dist/app/api/hazo_auth/invalidate_cache/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/invalidate_cache/route.js +96 -0
- package/dist/app/api/hazo_auth/library_photos/route.d.ts +13 -0
- package/dist/app/api/hazo_auth/library_photos/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/library_photos/route.js +55 -0
- package/dist/app/api/hazo_auth/login/route.d.ts +12 -0
- package/dist/app/api/hazo_auth/login/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/login/route.js +140 -0
- package/dist/app/api/hazo_auth/logout/route.d.ts +8 -0
- package/dist/app/api/hazo_auth/logout/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/logout/route.js +71 -0
- package/dist/app/api/hazo_auth/me/route.d.ts +3 -0
- package/dist/app/api/hazo_auth/me/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/me/route.js +34 -0
- package/dist/app/api/hazo_auth/profile_picture/[filename]/route.d.ts +7 -0
- package/dist/app/api/hazo_auth/profile_picture/[filename]/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/profile_picture/[filename]/route.js +43 -0
- package/dist/app/api/hazo_auth/register/route.d.ts +9 -0
- package/dist/app/api/hazo_auth/register/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/register/route.js +80 -0
- package/dist/app/api/hazo_auth/remove_profile_picture/route.d.ts +8 -0
- package/dist/app/api/hazo_auth/remove_profile_picture/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/remove_profile_picture/route.js +64 -0
- package/dist/app/api/hazo_auth/resend_verification/route.d.ts +8 -0
- package/dist/app/api/hazo_auth/resend_verification/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/resend_verification/route.js +79 -0
- package/dist/app/api/hazo_auth/reset_password/route.d.ts +8 -0
- package/dist/app/api/hazo_auth/reset_password/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/reset_password/route.js +76 -0
- package/dist/app/api/hazo_auth/update_user/route.d.ts +9 -0
- package/dist/app/api/hazo_auth/update_user/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/update_user/route.js +95 -0
- package/dist/app/api/hazo_auth/upload_profile_picture/route.d.ts +9 -0
- package/dist/app/api/hazo_auth/upload_profile_picture/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/upload_profile_picture/route.js +204 -0
- package/dist/app/api/hazo_auth/validate_reset_token/route.d.ts +6 -0
- package/dist/app/api/hazo_auth/validate_reset_token/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/validate_reset_token/route.js +58 -0
- package/dist/app/api/hazo_auth/verify_email/route.d.ts +11 -0
- package/dist/app/api/hazo_auth/verify_email/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/verify_email/route.js +63 -0
- package/dist/cli/generate.d.ts +2 -0
- package/dist/cli/generate.d.ts.map +1 -0
- package/dist/cli/generate.js +117 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +120 -0
- package/dist/cli/validate.d.ts +15 -0
- package/dist/cli/validate.d.ts.map +1 -0
- package/dist/cli/validate.js +509 -0
- package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts +2 -2
- package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/config/email_verification_field_config.js +1 -1
- package/dist/components/layouts/email_verification/hooks/use_email_verification.d.ts +2 -2
- package/dist/components/layouts/email_verification/hooks/use_email_verification.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/hooks/use_email_verification.js +2 -2
- package/dist/components/layouts/email_verification/index.d.ts +3 -3
- package/dist/components/layouts/email_verification/index.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/index.js +9 -9
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts +2 -2
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.js +1 -1
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts +2 -2
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.js +2 -2
- package/dist/components/layouts/forgot_password/index.d.ts +2 -2
- package/dist/components/layouts/forgot_password/index.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/index.js +8 -8
- package/dist/components/layouts/login/config/login_field_config.d.ts +2 -2
- package/dist/components/layouts/login/config/login_field_config.d.ts.map +1 -1
- package/dist/components/layouts/login/config/login_field_config.js +1 -1
- package/dist/components/layouts/login/hooks/use_login_form.d.ts +2 -2
- package/dist/components/layouts/login/hooks/use_login_form.d.ts.map +1 -1
- package/dist/components/layouts/login/hooks/use_login_form.js +4 -4
- package/dist/components/layouts/login/index.d.ts +2 -2
- package/dist/components/layouts/login/index.d.ts.map +1 -1
- package/dist/components/layouts/login/index.js +9 -9
- package/dist/components/layouts/my_settings/components/editable_field.js +3 -3
- package/dist/components/layouts/my_settings/components/password_change_dialog.d.ts +1 -1
- package/dist/components/layouts/my_settings/components/password_change_dialog.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/password_change_dialog.js +4 -4
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.js +7 -7
- package/dist/components/layouts/my_settings/components/profile_picture_display.js +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.js +3 -3
- package/dist/components/layouts/my_settings/components/profile_picture_library_tab.js +5 -5
- package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.js +4 -4
- package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts +1 -1
- package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/config/my_settings_field_config.js +1 -1
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts +1 -1
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/hooks/use_my_settings.js +1 -1
- package/dist/components/layouts/my_settings/index.d.ts +2 -2
- package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/index.js +9 -9
- package/dist/components/layouts/register/config/register_field_config.d.ts +2 -2
- package/dist/components/layouts/register/config/register_field_config.d.ts.map +1 -1
- package/dist/components/layouts/register/config/register_field_config.js +1 -1
- package/dist/components/layouts/register/hooks/use_register_form.d.ts +3 -3
- package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -1
- package/dist/components/layouts/register/hooks/use_register_form.js +2 -2
- package/dist/components/layouts/register/index.d.ts +2 -2
- package/dist/components/layouts/register/index.d.ts.map +1 -1
- package/dist/components/layouts/register/index.js +9 -9
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts +2 -2
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/config/reset_password_field_config.js +1 -1
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.d.ts +3 -3
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.js +2 -2
- package/dist/components/layouts/reset_password/index.d.ts +2 -2
- package/dist/components/layouts/reset_password/index.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/index.js +8 -8
- package/dist/components/layouts/shared/components/already_logged_in_guard.js +4 -4
- package/dist/components/layouts/shared/components/auth_page_shell.js +3 -3
- package/dist/components/layouts/shared/components/form_action_buttons.d.ts +1 -1
- package/dist/components/layouts/shared/components/form_action_buttons.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/form_action_buttons.js +1 -1
- package/dist/components/layouts/shared/components/form_field_wrapper.js +2 -2
- package/dist/components/layouts/shared/components/logout_button.js +2 -2
- package/dist/components/layouts/shared/components/password_field.js +3 -3
- package/dist/components/layouts/shared/components/profile_pic_menu.d.ts +1 -1
- package/dist/components/layouts/shared/components/profile_pic_menu.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/profile_pic_menu.js +4 -4
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.js +2 -2
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.js +3 -3
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.js +1 -1
- package/dist/components/layouts/shared/components/two_column_auth_layout.js +1 -1
- package/dist/components/layouts/shared/components/unauthorized_guard.js +2 -2
- package/dist/components/layouts/shared/hooks/use_hazo_auth.d.ts +1 -1
- package/dist/components/layouts/shared/hooks/use_hazo_auth.d.ts.map +1 -1
- package/dist/components/layouts/shared/utils/validation.d.ts +1 -1
- package/dist/components/layouts/shared/utils/validation.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/roles_matrix.js +7 -7
- package/dist/components/layouts/user_management/index.js +11 -11
- package/dist/components/ui/alert-dialog.js +2 -2
- package/dist/components/ui/avatar.js +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/card.js +45 -0
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/dropdown-menu.js +1 -1
- package/dist/components/ui/hazo_ui_tooltip.js +1 -1
- package/dist/components/ui/input.js +1 -1
- package/dist/components/ui/label.js +1 -1
- package/dist/components/ui/separator.js +1 -1
- package/dist/components/ui/sheet.js +1 -1
- package/dist/components/ui/sidebar.d.ts +2 -2
- package/dist/components/ui/sidebar.d.ts.map +1 -1
- package/dist/components/ui/sidebar.js +8 -8
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/table.js +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/tooltip.js +1 -1
- package/dist/components/ui/vertical-tabs.js +1 -1
- package/dist/hooks/use-mobile.d.ts.map +1 -1
- package/dist/hooks/use-mobile.js +17 -3
- package/dist/lib/already_logged_in_config.server.js +1 -1
- package/dist/lib/app_logger.js +1 -1
- package/dist/lib/auth/auth_cache.d.ts +1 -1
- package/dist/lib/auth/auth_cache.d.ts.map +1 -1
- package/dist/lib/auth/auth_utils.server.js +2 -2
- package/dist/lib/auth/hazo_get_auth.server.d.ts +1 -1
- package/dist/lib/auth/hazo_get_auth.server.d.ts.map +1 -1
- package/dist/lib/auth/hazo_get_auth.server.js +7 -7
- package/dist/lib/auth/server_auth.js +2 -2
- package/dist/lib/auth_utility_config.server.js +1 -1
- package/dist/lib/config/config_loader.server.js +1 -1
- package/dist/lib/email_verification_config.server.js +1 -1
- package/dist/lib/file_types_config.server.js +1 -1
- package/dist/lib/forgot_password_config.server.js +1 -1
- package/dist/lib/hazo_connect_instance.server.js +2 -2
- package/dist/lib/hazo_connect_setup.server.js +2 -2
- package/dist/lib/login_config.server.js +2 -2
- package/dist/lib/messages_config.server.js +1 -1
- package/dist/lib/my_settings_config.server.js +7 -7
- package/dist/lib/password_requirements_config.server.js +1 -1
- package/dist/lib/profile_pic_menu_config.server.js +1 -1
- package/dist/lib/profile_picture_config.server.js +2 -2
- package/dist/lib/register_config.server.js +4 -4
- package/dist/lib/reset_password_config.server.js +3 -3
- package/dist/lib/services/email_service.js +2 -2
- package/dist/lib/services/email_verification_service.js +3 -3
- package/dist/lib/services/login_service.js +3 -3
- package/dist/lib/services/password_change_service.js +3 -3
- package/dist/lib/services/password_reset_service.js +3 -3
- package/dist/lib/services/profile_picture_remove_service.js +3 -3
- package/dist/lib/services/profile_picture_service.d.ts +1 -1
- package/dist/lib/services/profile_picture_service.d.ts.map +1 -1
- package/dist/lib/services/profile_picture_service.js +5 -5
- package/dist/lib/services/registration_service.js +8 -8
- package/dist/lib/services/token_service.js +2 -2
- package/dist/lib/services/user_profiles_service.js +2 -2
- package/dist/lib/services/user_update_service.d.ts +1 -1
- package/dist/lib/services/user_update_service.d.ts.map +1 -1
- package/dist/lib/services/user_update_service.js +4 -4
- package/dist/lib/ui_shell_config.server.js +1 -1
- package/dist/lib/ui_sizes_config.server.js +1 -1
- package/dist/lib/user_fields_config.server.js +1 -1
- package/dist/lib/user_management_config.server.js +1 -1
- package/dist/lib/utils/error_sanitizer.d.ts +1 -1
- package/dist/lib/utils/error_sanitizer.d.ts.map +1 -1
- package/dist/server/config/config_loader.d.ts +1 -1
- package/dist/server/config/config_loader.d.ts.map +1 -1
- package/dist/server/config/config_loader.js +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/logging/logger_service.d.ts +1 -1
- package/dist/server/logging/logger_service.d.ts.map +1 -1
- package/dist/server/routes/change_password.d.ts +2 -0
- package/dist/server/routes/change_password.d.ts.map +1 -0
- package/dist/server/routes/change_password.js +2 -0
- package/dist/server/routes/forgot_password.d.ts +2 -0
- package/dist/server/routes/forgot_password.d.ts.map +1 -0
- package/dist/server/routes/forgot_password.js +2 -0
- package/dist/server/routes/get_auth.d.ts +2 -0
- package/dist/server/routes/get_auth.d.ts.map +1 -0
- package/dist/server/routes/get_auth.js +2 -0
- package/dist/server/routes/index.d.ts +18 -0
- package/dist/server/routes/index.d.ts.map +1 -0
- package/dist/server/routes/index.js +24 -0
- package/dist/server/routes/invalidate_cache.d.ts +2 -0
- package/dist/server/routes/invalidate_cache.d.ts.map +1 -0
- package/dist/server/routes/invalidate_cache.js +2 -0
- package/dist/server/routes/library_photos.d.ts +2 -0
- package/dist/server/routes/library_photos.d.ts.map +1 -0
- package/dist/server/routes/library_photos.js +2 -0
- package/dist/server/routes/login.d.ts +2 -0
- package/dist/server/routes/login.d.ts.map +1 -0
- package/dist/server/routes/login.js +2 -0
- package/dist/server/routes/logout.d.ts +2 -0
- package/dist/server/routes/logout.d.ts.map +1 -0
- package/dist/server/routes/logout.js +2 -0
- package/dist/server/routes/me.d.ts +2 -0
- package/dist/server/routes/me.d.ts.map +1 -0
- package/dist/server/routes/me.js +2 -0
- package/dist/server/routes/profile_picture_filename.d.ts +2 -0
- package/dist/server/routes/profile_picture_filename.d.ts.map +1 -0
- package/dist/server/routes/profile_picture_filename.js +3 -0
- package/dist/server/routes/register.d.ts +2 -0
- package/dist/server/routes/register.d.ts.map +1 -0
- package/dist/server/routes/register.js +2 -0
- package/dist/server/routes/remove_profile_picture.d.ts +2 -0
- package/dist/server/routes/remove_profile_picture.d.ts.map +1 -0
- package/dist/server/routes/remove_profile_picture.js +2 -0
- package/dist/server/routes/resend_verification.d.ts +2 -0
- package/dist/server/routes/resend_verification.d.ts.map +1 -0
- package/dist/server/routes/resend_verification.js +2 -0
- package/dist/server/routes/reset_password.d.ts +2 -0
- package/dist/server/routes/reset_password.d.ts.map +1 -0
- package/dist/server/routes/reset_password.js +2 -0
- package/dist/server/routes/update_user.d.ts +2 -0
- package/dist/server/routes/update_user.d.ts.map +1 -0
- package/dist/server/routes/update_user.js +2 -0
- package/dist/server/routes/upload_profile_picture.d.ts +2 -0
- package/dist/server/routes/upload_profile_picture.d.ts.map +1 -0
- package/dist/server/routes/upload_profile_picture.js +2 -0
- package/dist/server/routes/validate_reset_token.d.ts +2 -0
- package/dist/server/routes/validate_reset_token.d.ts.map +1 -0
- package/dist/server/routes/validate_reset_token.js +2 -0
- package/dist/server/routes/verify_email.d.ts +2 -0
- package/dist/server/routes/verify_email.d.ts.map +1 -0
- package/dist/server/routes/verify_email.js +2 -0
- package/dist/server/server.js +2 -2
- package/package.json +14 -115
- package/components.json +0 -22
- package/instrumentation.ts +0 -32
- package/migrations/001_add_token_type_to_refresh_tokens.sql +0 -14
- package/migrations/002_add_name_to_hazo_users.sql +0 -7
- package/migrations/003_add_url_on_logon_to_hazo_users.sql +0 -8
- package/next.config.mjs +0 -67
- package/postcss.config.mjs +0 -8
- package/public/file.svg +0 -1
- package/public/globe.svg +0 -1
- package/public/next.svg +0 -1
- package/public/vercel.svg +0 -1
- package/public/window.svg +0 -1
- package/scripts/apply_migration.ts +0 -118
- package/scripts/init_users.ts +0 -378
- package/src/app/api/hazo_auth/auth/upload_profile_picture/route.ts +0 -268
- package/src/app/api/hazo_auth/change_password/route.ts +0 -132
- package/src/app/api/hazo_auth/forgot_password/route.ts +0 -107
- package/src/app/api/hazo_auth/get_auth/route.ts +0 -89
- package/src/app/api/hazo_auth/invalidate_cache/route.ts +0 -139
- package/src/app/api/hazo_auth/library_photos/route.ts +0 -73
- package/src/app/api/hazo_auth/login/route.ts +0 -181
- package/src/app/api/hazo_auth/logout/route.ts +0 -89
- package/src/app/api/hazo_auth/me/route.ts +0 -47
- package/src/app/api/hazo_auth/profile_picture/[filename]/route.ts +0 -67
- package/src/app/api/hazo_auth/register/route.ts +0 -109
- package/src/app/api/hazo_auth/remove_profile_picture/route.ts +0 -86
- package/src/app/api/hazo_auth/resend_verification/route.ts +0 -108
- package/src/app/api/hazo_auth/reset_password/route.ts +0 -107
- package/src/app/api/hazo_auth/update_user/route.ts +0 -126
- package/src/app/api/hazo_auth/upload_profile_picture/route.ts +0 -268
- package/src/app/api/hazo_auth/user_management/permissions/route.ts +0 -367
- package/src/app/api/hazo_auth/user_management/roles/route.ts +0 -442
- package/src/app/api/hazo_auth/user_management/users/roles/route.ts +0 -367
- package/src/app/api/hazo_auth/user_management/users/route.ts +0 -239
- package/src/app/api/hazo_auth/validate_reset_token/route.ts +0 -83
- package/src/app/api/hazo_auth/verify_email/route.ts +0 -88
- package/src/app/api/migrations/apply/route.ts +0 -91
- package/src/app/favicon.ico +0 -0
- package/src/app/fonts/GeistMonoVF.woff +0 -0
- package/src/app/fonts/GeistVF.woff +0 -0
- package/src/app/globals.css +0 -89
- package/src/app/hazo_auth/forgot_password/forgot_password_page_client.tsx +0 -60
- package/src/app/hazo_auth/forgot_password/page.tsx +0 -24
- package/src/app/hazo_auth/login/login_page_client.tsx +0 -86
- package/src/app/hazo_auth/login/page.tsx +0 -38
- package/src/app/hazo_auth/my_settings/my_settings_page_client.tsx +0 -120
- package/src/app/hazo_auth/my_settings/page.tsx +0 -40
- package/src/app/hazo_auth/register/page.tsx +0 -36
- package/src/app/hazo_auth/register/register_page_client.tsx +0 -81
- package/src/app/hazo_auth/reset_password/page.tsx +0 -29
- package/src/app/hazo_auth/reset_password/reset_password_page_client.tsx +0 -81
- package/src/app/hazo_auth/user_management/page.tsx +0 -14
- package/src/app/hazo_auth/user_management/user_management_page_client.tsx +0 -16
- package/src/app/hazo_auth/verify_email/page.tsx +0 -24
- package/src/app/hazo_auth/verify_email/verify_email_page_client.tsx +0 -60
- package/src/app/hazo_connect/api/sqlite/data/route.ts +0 -203
- package/src/app/hazo_connect/api/sqlite/schema/route.ts +0 -45
- package/src/app/hazo_connect/api/sqlite/tables/route.ts +0 -36
- package/src/app/hazo_connect/sqlite_admin/page.tsx +0 -51
- package/src/app/hazo_connect/sqlite_admin/sqlite-admin-client.tsx +0 -984
- package/src/app/layout.tsx +0 -43
- package/src/app/page.tsx +0 -170
- package/src/components/index.ts +0 -7
- package/src/components/layouts/email_verification/config/email_verification_field_config.ts +0 -86
- package/src/components/layouts/email_verification/hooks/use_email_verification.ts +0 -297
- package/src/components/layouts/email_verification/index.tsx +0 -297
- package/src/components/layouts/forgot_password/config/forgot_password_field_config.ts +0 -58
- package/src/components/layouts/forgot_password/hooks/use_forgot_password_form.ts +0 -179
- package/src/components/layouts/forgot_password/index.tsx +0 -168
- package/src/components/layouts/index.ts +0 -26
- package/src/components/layouts/login/config/login_field_config.ts +0 -67
- package/src/components/layouts/login/hooks/use_login_form.ts +0 -286
- package/src/components/layouts/login/index.tsx +0 -252
- package/src/components/layouts/my_settings/components/editable_field.tsx +0 -177
- package/src/components/layouts/my_settings/components/password_change_dialog.tsx +0 -301
- package/src/components/layouts/my_settings/components/profile_picture_dialog.tsx +0 -385
- package/src/components/layouts/my_settings/components/profile_picture_display.tsx +0 -66
- package/src/components/layouts/my_settings/components/profile_picture_gravatar_tab.tsx +0 -143
- package/src/components/layouts/my_settings/components/profile_picture_library_tab.tsx +0 -311
- package/src/components/layouts/my_settings/components/profile_picture_upload_tab.tsx +0 -341
- package/src/components/layouts/my_settings/config/my_settings_field_config.ts +0 -61
- package/src/components/layouts/my_settings/hooks/use_my_settings.ts +0 -458
- package/src/components/layouts/my_settings/index.tsx +0 -351
- package/src/components/layouts/register/config/register_field_config.ts +0 -101
- package/src/components/layouts/register/hooks/use_register_form.ts +0 -275
- package/src/components/layouts/register/index.tsx +0 -226
- package/src/components/layouts/reset_password/config/reset_password_field_config.ts +0 -86
- package/src/components/layouts/reset_password/hooks/use_reset_password_form.ts +0 -276
- package/src/components/layouts/reset_password/index.tsx +0 -294
- package/src/components/layouts/shared/components/already_logged_in_guard.tsx +0 -95
- package/src/components/layouts/shared/components/auth_page_shell.tsx +0 -36
- package/src/components/layouts/shared/components/field_error_message.tsx +0 -29
- package/src/components/layouts/shared/components/form_action_buttons.tsx +0 -64
- package/src/components/layouts/shared/components/form_field_wrapper.tsx +0 -44
- package/src/components/layouts/shared/components/form_header.tsx +0 -36
- package/src/components/layouts/shared/components/logout_button.tsx +0 -76
- package/src/components/layouts/shared/components/password_field.tsx +0 -72
- package/src/components/layouts/shared/components/profile_pic_menu.tsx +0 -321
- package/src/components/layouts/shared/components/profile_pic_menu_wrapper.tsx +0 -40
- package/src/components/layouts/shared/components/sidebar_layout_wrapper.tsx +0 -214
- package/src/components/layouts/shared/components/standalone_layout_wrapper.tsx +0 -53
- package/src/components/layouts/shared/components/two_column_auth_layout.tsx +0 -44
- package/src/components/layouts/shared/components/unauthorized_guard.tsx +0 -78
- package/src/components/layouts/shared/components/visual_panel.tsx +0 -41
- package/src/components/layouts/shared/config/layout_customization.ts +0 -95
- package/src/components/layouts/shared/data/layout_data_client.ts +0 -19
- package/src/components/layouts/shared/hooks/use_auth_status.ts +0 -103
- package/src/components/layouts/shared/hooks/use_hazo_auth.ts +0 -158
- package/src/components/layouts/shared/index.ts +0 -34
- package/src/components/layouts/shared/utils/ip_address.ts +0 -37
- package/src/components/layouts/shared/utils/validation.ts +0 -66
- package/src/components/layouts/user_management/components/roles_matrix.tsx +0 -607
- package/src/components/layouts/user_management/index.tsx +0 -1295
- package/src/components/ui/alert-dialog.tsx +0 -141
- package/src/components/ui/avatar.tsx +0 -50
- package/src/components/ui/button.tsx +0 -57
- package/src/components/ui/checkbox.tsx +0 -30
- package/src/components/ui/dialog.tsx +0 -122
- package/src/components/ui/dropdown-menu.tsx +0 -201
- package/src/components/ui/hazo_ui_tooltip.tsx +0 -67
- package/src/components/ui/index.ts +0 -22
- package/src/components/ui/input.tsx +0 -22
- package/src/components/ui/label.tsx +0 -26
- package/src/components/ui/separator.tsx +0 -31
- package/src/components/ui/sheet.tsx +0 -139
- package/src/components/ui/sidebar.tsx +0 -773
- package/src/components/ui/skeleton.tsx +0 -15
- package/src/components/ui/sonner.tsx +0 -31
- package/src/components/ui/switch.tsx +0 -29
- package/src/components/ui/table.tsx +0 -120
- package/src/components/ui/tabs.tsx +0 -55
- package/src/components/ui/tooltip.tsx +0 -32
- package/src/components/ui/vertical-tabs.tsx +0 -59
- package/src/hooks/use-mobile.tsx +0 -19
- package/src/index.ts +0 -7
- package/src/lib/already_logged_in_config.server.ts +0 -46
- package/src/lib/app_logger.ts +0 -24
- package/src/lib/auth/auth_cache.ts +0 -220
- package/src/lib/auth/auth_rate_limiter.ts +0 -121
- package/src/lib/auth/auth_types.ts +0 -65
- package/src/lib/auth/auth_utils.server.ts +0 -196
- package/src/lib/auth/hazo_get_auth.server.ts +0 -333
- package/src/lib/auth/index.ts +0 -23
- package/src/lib/auth/server_auth.ts +0 -88
- package/src/lib/auth_utility_config.server.ts +0 -136
- package/src/lib/config/config_loader.server.ts +0 -164
- package/src/lib/email_verification_config.server.ts +0 -32
- package/src/lib/file_types_config.server.ts +0 -25
- package/src/lib/forgot_password_config.server.ts +0 -32
- package/src/lib/hazo_connect_instance.server.ts +0 -101
- package/src/lib/hazo_connect_setup.server.ts +0 -194
- package/src/lib/hazo_connect_setup.ts +0 -54
- package/src/lib/index.ts +0 -44
- package/src/lib/login_config.server.ts +0 -71
- package/src/lib/messages_config.server.ts +0 -45
- package/src/lib/migrations/apply_migration.ts +0 -105
- package/src/lib/my_settings_config.server.ts +0 -135
- package/src/lib/password_requirements_config.server.ts +0 -39
- package/src/lib/profile_pic_menu_config.server.ts +0 -138
- package/src/lib/profile_picture_config.server.ts +0 -56
- package/src/lib/register_config.server.ts +0 -73
- package/src/lib/reset_password_config.server.ts +0 -75
- package/src/lib/services/email_service.ts +0 -581
- package/src/lib/services/email_verification_service.ts +0 -270
- package/src/lib/services/index.ts +0 -15
- package/src/lib/services/login_service.ts +0 -134
- package/src/lib/services/password_change_service.ts +0 -154
- package/src/lib/services/password_reset_service.ts +0 -405
- package/src/lib/services/profile_picture_remove_service.ts +0 -120
- package/src/lib/services/profile_picture_service.ts +0 -215
- package/src/lib/services/profile_picture_source_mapper.ts +0 -62
- package/src/lib/services/registration_service.ts +0 -184
- package/src/lib/services/token_service.ts +0 -240
- package/src/lib/services/user_profiles_service.ts +0 -143
- package/src/lib/services/user_update_service.ts +0 -141
- package/src/lib/ui_shell_config.server.ts +0 -73
- package/src/lib/ui_sizes_config.server.ts +0 -37
- package/src/lib/user_fields_config.server.ts +0 -31
- package/src/lib/user_management_config.server.ts +0 -39
- package/src/lib/utils/api_route_helpers.ts +0 -60
- package/src/lib/utils/error_sanitizer.ts +0 -75
- package/src/lib/utils.ts +0 -11
- package/src/middleware.ts +0 -94
- package/src/routes/index.ts +0 -34
- package/src/server/config/config_loader.ts +0 -496
- package/src/server/index.ts +0 -38
- package/src/server/logging/logger_service.ts +0 -56
- package/src/server/routes/root_router.ts +0 -16
- package/src/server/server.ts +0 -28
- package/src/server/types/app_types.ts +0 -74
- package/src/server/types/express.d.ts +0 -16
- package/src/stories/email_verification_layout.stories.tsx +0 -137
- package/src/stories/forgot_password_layout.stories.tsx +0 -85
- package/src/stories/login_layout.stories.tsx +0 -85
- package/src/stories/project_overview.stories.tsx +0 -33
- package/src/stories/register_layout.stories.tsx +0 -107
- package/tailwind.config.ts +0 -77
- package/tsconfig.build.json +0 -39
- package/tsconfig.json +0 -28
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
// file_description: encapsulate register form state, validation, and data interactions
|
|
2
|
-
// section: imports
|
|
3
|
-
import { useCallback, useMemo, useState } from "react";
|
|
4
|
-
import { toast } from "sonner";
|
|
5
|
-
import type { LayoutDataClient } from "hazo_auth/components/layouts/shared/data/layout_data_client";
|
|
6
|
-
import type { PasswordRequirementOptions, PasswordRequirementOverrides } from "hazo_auth/components/layouts/shared/config/layout_customization";
|
|
7
|
-
import { REGISTER_FIELD_IDS, type RegisterFieldId } from "hazo_auth/components/layouts/register/config/register_field_config";
|
|
8
|
-
import { validateEmail, validatePassword } from "hazo_auth/components/layouts/shared/utils/validation";
|
|
9
|
-
|
|
10
|
-
// section: constants
|
|
11
|
-
const PASSWORD_FIELDS: Array<RegisterFieldId> = [
|
|
12
|
-
REGISTER_FIELD_IDS.PASSWORD,
|
|
13
|
-
REGISTER_FIELD_IDS.CONFIRM_PASSWORD,
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
// section: types
|
|
17
|
-
export type RegisterFormValues = Record<RegisterFieldId, string>;
|
|
18
|
-
export type RegisterFormErrors = Partial<Record<RegisterFieldId, string | string[]>> & {
|
|
19
|
-
submit?: string;
|
|
20
|
-
};
|
|
21
|
-
export type PasswordVisibilityState = Record<
|
|
22
|
-
Extract<RegisterFieldId, "password" | "confirm_password">,
|
|
23
|
-
boolean
|
|
24
|
-
>;
|
|
25
|
-
|
|
26
|
-
export type UseRegisterFormParams<TClient = unknown> = {
|
|
27
|
-
showNameField: boolean;
|
|
28
|
-
passwordRequirements: PasswordRequirementOptions;
|
|
29
|
-
passwordRequirementOverrides?: PasswordRequirementOverrides;
|
|
30
|
-
dataClient: LayoutDataClient<TClient>;
|
|
31
|
-
urlOnLogon?: string;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export type UseRegisterFormResult = {
|
|
35
|
-
values: RegisterFormValues;
|
|
36
|
-
errors: RegisterFormErrors;
|
|
37
|
-
passwordVisibility: PasswordVisibilityState;
|
|
38
|
-
isSubmitDisabled: boolean;
|
|
39
|
-
isSubmitting: boolean;
|
|
40
|
-
emailTouched: boolean;
|
|
41
|
-
handleFieldChange: (fieldId: RegisterFieldId, value: string) => void;
|
|
42
|
-
handleEmailBlur: () => void;
|
|
43
|
-
togglePasswordVisibility: (fieldId: "password" | "confirm_password") => void;
|
|
44
|
-
handleSubmit: (event: React.FormEvent<HTMLFormElement>) => void;
|
|
45
|
-
handleCancel: () => void;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// section: helpers
|
|
49
|
-
const buildInitialValues = (): RegisterFormValues => ({
|
|
50
|
-
[REGISTER_FIELD_IDS.NAME]: "",
|
|
51
|
-
[REGISTER_FIELD_IDS.EMAIL]: "",
|
|
52
|
-
[REGISTER_FIELD_IDS.PASSWORD]: "",
|
|
53
|
-
[REGISTER_FIELD_IDS.CONFIRM_PASSWORD]: "",
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// section: hook
|
|
58
|
-
export const use_register_form = <TClient,>({
|
|
59
|
-
showNameField,
|
|
60
|
-
passwordRequirements,
|
|
61
|
-
dataClient,
|
|
62
|
-
urlOnLogon,
|
|
63
|
-
}: UseRegisterFormParams<TClient>): UseRegisterFormResult => {
|
|
64
|
-
const [values, setValues] = useState<RegisterFormValues>(buildInitialValues);
|
|
65
|
-
const [errors, setErrors] = useState<RegisterFormErrors>({});
|
|
66
|
-
const [passwordVisibility, setPasswordVisibility] = useState<PasswordVisibilityState>({
|
|
67
|
-
password: false,
|
|
68
|
-
confirm_password: false,
|
|
69
|
-
});
|
|
70
|
-
const [emailTouched, setEmailTouched] = useState<boolean>(false);
|
|
71
|
-
const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
|
|
72
|
-
|
|
73
|
-
const isSubmitDisabled = useMemo(() => {
|
|
74
|
-
if (isSubmitting) {
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const hasEmptyField = Object.entries(values).some(([fieldId, fieldValue]) => {
|
|
79
|
-
if (fieldId === REGISTER_FIELD_IDS.NAME && !showNameField) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
return fieldValue.trim() === "";
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const hasErrors = Object.keys(errors).length > 0;
|
|
86
|
-
return hasEmptyField || hasErrors;
|
|
87
|
-
}, [errors, showNameField, values, isSubmitting]);
|
|
88
|
-
|
|
89
|
-
const togglePasswordVisibility = useCallback((fieldId: "password" | "confirm_password") => {
|
|
90
|
-
setPasswordVisibility((previous) => ({
|
|
91
|
-
...previous,
|
|
92
|
-
[fieldId]: !previous[fieldId],
|
|
93
|
-
}));
|
|
94
|
-
}, []);
|
|
95
|
-
|
|
96
|
-
const handleFieldChange = useCallback(
|
|
97
|
-
(fieldId: RegisterFieldId, value: string) => {
|
|
98
|
-
setValues((previousValues) => {
|
|
99
|
-
const nextValues: RegisterFormValues = {
|
|
100
|
-
...previousValues,
|
|
101
|
-
[fieldId]: value,
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
setErrors((previousErrors) => {
|
|
105
|
-
const updatedErrors: RegisterFormErrors = { ...previousErrors };
|
|
106
|
-
|
|
107
|
-
// Only validate email on change if it has been touched (blurred)
|
|
108
|
-
if (fieldId === REGISTER_FIELD_IDS.EMAIL && emailTouched) {
|
|
109
|
-
const emailError = validateEmail(value);
|
|
110
|
-
if (emailError) {
|
|
111
|
-
updatedErrors[REGISTER_FIELD_IDS.EMAIL] = emailError;
|
|
112
|
-
} else {
|
|
113
|
-
delete updatedErrors[REGISTER_FIELD_IDS.EMAIL];
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (PASSWORD_FIELDS.includes(fieldId)) {
|
|
118
|
-
const passwordError = validatePassword(
|
|
119
|
-
nextValues[REGISTER_FIELD_IDS.PASSWORD],
|
|
120
|
-
passwordRequirements,
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
if (passwordError) {
|
|
124
|
-
updatedErrors[REGISTER_FIELD_IDS.PASSWORD] = passwordError;
|
|
125
|
-
} else {
|
|
126
|
-
delete updatedErrors[REGISTER_FIELD_IDS.PASSWORD];
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (
|
|
130
|
-
nextValues[REGISTER_FIELD_IDS.CONFIRM_PASSWORD].trim().length > 0 &&
|
|
131
|
-
nextValues[REGISTER_FIELD_IDS.PASSWORD] !==
|
|
132
|
-
nextValues[REGISTER_FIELD_IDS.CONFIRM_PASSWORD]
|
|
133
|
-
) {
|
|
134
|
-
updatedErrors[REGISTER_FIELD_IDS.CONFIRM_PASSWORD] = "passwords do not match";
|
|
135
|
-
} else {
|
|
136
|
-
delete updatedErrors[REGISTER_FIELD_IDS.CONFIRM_PASSWORD];
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return updatedErrors;
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
return nextValues;
|
|
144
|
-
});
|
|
145
|
-
},
|
|
146
|
-
[passwordRequirements, emailTouched],
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
const handleEmailBlur = useCallback(() => {
|
|
150
|
-
setEmailTouched(true);
|
|
151
|
-
// Validate email on blur
|
|
152
|
-
setErrors((previousErrors) => {
|
|
153
|
-
const updatedErrors: RegisterFormErrors = { ...previousErrors };
|
|
154
|
-
const emailValue = values[REGISTER_FIELD_IDS.EMAIL];
|
|
155
|
-
const emailError = validateEmail(emailValue);
|
|
156
|
-
if (emailError) {
|
|
157
|
-
updatedErrors[REGISTER_FIELD_IDS.EMAIL] = emailError;
|
|
158
|
-
} else {
|
|
159
|
-
delete updatedErrors[REGISTER_FIELD_IDS.EMAIL];
|
|
160
|
-
}
|
|
161
|
-
return updatedErrors;
|
|
162
|
-
});
|
|
163
|
-
}, [values]);
|
|
164
|
-
|
|
165
|
-
const handleSubmit = useCallback(
|
|
166
|
-
async (event: React.FormEvent<HTMLFormElement>) => {
|
|
167
|
-
event.preventDefault();
|
|
168
|
-
|
|
169
|
-
// Final validation
|
|
170
|
-
const emailError = validateEmail(values[REGISTER_FIELD_IDS.EMAIL]);
|
|
171
|
-
const passwordError = validatePassword(
|
|
172
|
-
values[REGISTER_FIELD_IDS.PASSWORD],
|
|
173
|
-
passwordRequirements,
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
if (emailError || passwordError) {
|
|
177
|
-
setErrors({
|
|
178
|
-
...(emailError ? { [REGISTER_FIELD_IDS.EMAIL]: emailError } : {}),
|
|
179
|
-
...(passwordError ? { [REGISTER_FIELD_IDS.PASSWORD]: passwordError } : {}),
|
|
180
|
-
});
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Check password match
|
|
185
|
-
if (
|
|
186
|
-
values[REGISTER_FIELD_IDS.PASSWORD] !==
|
|
187
|
-
values[REGISTER_FIELD_IDS.CONFIRM_PASSWORD]
|
|
188
|
-
) {
|
|
189
|
-
setErrors({
|
|
190
|
-
[REGISTER_FIELD_IDS.CONFIRM_PASSWORD]: "passwords do not match",
|
|
191
|
-
});
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
setIsSubmitting(true);
|
|
196
|
-
setErrors({});
|
|
197
|
-
|
|
198
|
-
try {
|
|
199
|
-
const response = await fetch("/api/hazo_auth/register", {
|
|
200
|
-
method: "POST",
|
|
201
|
-
headers: {
|
|
202
|
-
"Content-Type": "application/json",
|
|
203
|
-
},
|
|
204
|
-
body: JSON.stringify({
|
|
205
|
-
name: values[REGISTER_FIELD_IDS.NAME] || undefined,
|
|
206
|
-
email: values[REGISTER_FIELD_IDS.EMAIL],
|
|
207
|
-
password: values[REGISTER_FIELD_IDS.PASSWORD],
|
|
208
|
-
url_on_logon: urlOnLogon,
|
|
209
|
-
}),
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
const data = await response.json();
|
|
213
|
-
|
|
214
|
-
if (!response.ok) {
|
|
215
|
-
throw new Error(data.error || "Registration failed");
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Show success notification
|
|
219
|
-
toast.success("Registration successful!", {
|
|
220
|
-
description: "Your account has been created successfully.",
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
// Reset form on success
|
|
224
|
-
setValues(buildInitialValues());
|
|
225
|
-
setErrors({});
|
|
226
|
-
setPasswordVisibility({
|
|
227
|
-
password: false,
|
|
228
|
-
confirm_password: false,
|
|
229
|
-
});
|
|
230
|
-
setEmailTouched(false);
|
|
231
|
-
} catch (error) {
|
|
232
|
-
const errorMessage =
|
|
233
|
-
error instanceof Error ? error.message : "Registration failed. Please try again.";
|
|
234
|
-
|
|
235
|
-
// Show error notification
|
|
236
|
-
toast.error("Registration failed", {
|
|
237
|
-
description: errorMessage,
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
// Set error state
|
|
241
|
-
setErrors({
|
|
242
|
-
submit: errorMessage,
|
|
243
|
-
});
|
|
244
|
-
} finally {
|
|
245
|
-
setIsSubmitting(false);
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
[values, passwordRequirements, dataClient, urlOnLogon],
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
const handleCancel = useCallback(() => {
|
|
252
|
-
setValues(buildInitialValues());
|
|
253
|
-
setErrors({});
|
|
254
|
-
setPasswordVisibility({
|
|
255
|
-
password: false,
|
|
256
|
-
confirm_password: false,
|
|
257
|
-
});
|
|
258
|
-
setEmailTouched(false);
|
|
259
|
-
}, []);
|
|
260
|
-
|
|
261
|
-
return {
|
|
262
|
-
values,
|
|
263
|
-
errors,
|
|
264
|
-
passwordVisibility,
|
|
265
|
-
isSubmitDisabled,
|
|
266
|
-
isSubmitting,
|
|
267
|
-
emailTouched,
|
|
268
|
-
handleFieldChange,
|
|
269
|
-
handleEmailBlur,
|
|
270
|
-
togglePasswordVisibility,
|
|
271
|
-
handleSubmit,
|
|
272
|
-
handleCancel,
|
|
273
|
-
};
|
|
274
|
-
};
|
|
275
|
-
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
// file_description: register layout component built atop shared layout utilities
|
|
2
|
-
// section: client_directive
|
|
3
|
-
"use client";
|
|
4
|
-
|
|
5
|
-
// section: imports
|
|
6
|
-
import Link from "next/link";
|
|
7
|
-
import { Input } from "hazo_auth/components/ui/input";
|
|
8
|
-
import { PasswordField } from "hazo_auth/components/layouts/shared/components/password_field";
|
|
9
|
-
import { FormFieldWrapper } from "hazo_auth/components/layouts/shared/components/form_field_wrapper";
|
|
10
|
-
import { FormHeader } from "hazo_auth/components/layouts/shared/components/form_header";
|
|
11
|
-
import { FormActionButtons } from "hazo_auth/components/layouts/shared/components/form_action_buttons";
|
|
12
|
-
import { TwoColumnAuthLayout } from "hazo_auth/components/layouts/shared/components/two_column_auth_layout";
|
|
13
|
-
import { AlreadyLoggedInGuard } from "hazo_auth/components/layouts/shared/components/already_logged_in_guard";
|
|
14
|
-
import {
|
|
15
|
-
type ButtonPaletteOverrides,
|
|
16
|
-
type LayoutFieldMapOverrides,
|
|
17
|
-
type LayoutLabelOverrides,
|
|
18
|
-
type PasswordRequirementOverrides,
|
|
19
|
-
} from "hazo_auth/components/layouts/shared/config/layout_customization";
|
|
20
|
-
import {
|
|
21
|
-
REGISTER_FIELD_IDS,
|
|
22
|
-
createRegisterFieldDefinitions,
|
|
23
|
-
resolveRegisterButtonPalette,
|
|
24
|
-
resolveRegisterLabels,
|
|
25
|
-
resolveRegisterPasswordRequirements,
|
|
26
|
-
} from "hazo_auth/components/layouts/register/config/register_field_config";
|
|
27
|
-
import {
|
|
28
|
-
use_register_form,
|
|
29
|
-
type UseRegisterFormResult,
|
|
30
|
-
} from "hazo_auth/components/layouts/register/hooks/use_register_form";
|
|
31
|
-
import { type LayoutDataClient } from "hazo_auth/components/layouts/shared/data/layout_data_client";
|
|
32
|
-
|
|
33
|
-
// section: types
|
|
34
|
-
export type RegisterLayoutProps<TClient = unknown> = {
|
|
35
|
-
image_src: string;
|
|
36
|
-
image_alt: string;
|
|
37
|
-
image_background_color?: string;
|
|
38
|
-
field_overrides?: LayoutFieldMapOverrides;
|
|
39
|
-
labels?: LayoutLabelOverrides;
|
|
40
|
-
button_colors?: ButtonPaletteOverrides;
|
|
41
|
-
password_requirements?: PasswordRequirementOverrides;
|
|
42
|
-
show_name_field?: boolean;
|
|
43
|
-
data_client: LayoutDataClient<TClient>;
|
|
44
|
-
alreadyLoggedInMessage?: string;
|
|
45
|
-
showLogoutButton?: boolean;
|
|
46
|
-
showReturnHomeButton?: boolean;
|
|
47
|
-
returnHomeButtonLabel?: string;
|
|
48
|
-
returnHomePath?: string;
|
|
49
|
-
signInPath?: string;
|
|
50
|
-
signInLabel?: string;
|
|
51
|
-
urlOnLogon?: string;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const ORDERED_FIELDS: RegisterFieldId[] = [
|
|
55
|
-
REGISTER_FIELD_IDS.NAME,
|
|
56
|
-
REGISTER_FIELD_IDS.EMAIL,
|
|
57
|
-
REGISTER_FIELD_IDS.PASSWORD,
|
|
58
|
-
REGISTER_FIELD_IDS.CONFIRM_PASSWORD,
|
|
59
|
-
];
|
|
60
|
-
|
|
61
|
-
type RegisterFieldId = (typeof REGISTER_FIELD_IDS)[keyof typeof REGISTER_FIELD_IDS];
|
|
62
|
-
|
|
63
|
-
// section: component
|
|
64
|
-
export default function register_layout<TClient>({
|
|
65
|
-
image_src,
|
|
66
|
-
image_alt,
|
|
67
|
-
image_background_color = "#f1f5f9",
|
|
68
|
-
field_overrides,
|
|
69
|
-
labels,
|
|
70
|
-
button_colors,
|
|
71
|
-
password_requirements,
|
|
72
|
-
show_name_field = true,
|
|
73
|
-
data_client,
|
|
74
|
-
alreadyLoggedInMessage = "You are already logged in",
|
|
75
|
-
showLogoutButton = true,
|
|
76
|
-
showReturnHomeButton = false,
|
|
77
|
-
returnHomeButtonLabel = "Return home",
|
|
78
|
-
returnHomePath = "/",
|
|
79
|
-
signInPath = "/hazo_auth/login",
|
|
80
|
-
signInLabel = "Sign in",
|
|
81
|
-
urlOnLogon,
|
|
82
|
-
}: RegisterLayoutProps<TClient>) {
|
|
83
|
-
const fieldDefinitions = createRegisterFieldDefinitions(field_overrides);
|
|
84
|
-
const resolvedLabels = resolveRegisterLabels(labels);
|
|
85
|
-
const resolvedButtonPalette = resolveRegisterButtonPalette(button_colors);
|
|
86
|
-
const resolvedPasswordRequirements = resolveRegisterPasswordRequirements(
|
|
87
|
-
password_requirements,
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const form = use_register_form({
|
|
91
|
-
showNameField: show_name_field,
|
|
92
|
-
passwordRequirements: resolvedPasswordRequirements,
|
|
93
|
-
dataClient: data_client,
|
|
94
|
-
urlOnLogon: urlOnLogon,
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const renderFields = (formState: UseRegisterFormResult) => {
|
|
98
|
-
const renderOrder = ORDERED_FIELDS.filter(
|
|
99
|
-
(fieldId) => show_name_field || fieldId !== REGISTER_FIELD_IDS.NAME,
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
return renderOrder.map((fieldId) => {
|
|
103
|
-
const fieldDefinition = fieldDefinitions[fieldId];
|
|
104
|
-
const fieldValue = formState.values[fieldId];
|
|
105
|
-
const fieldError = formState.errors[fieldId];
|
|
106
|
-
|
|
107
|
-
const isPasswordField =
|
|
108
|
-
fieldDefinition.type === "password" &&
|
|
109
|
-
(fieldId === REGISTER_FIELD_IDS.PASSWORD ||
|
|
110
|
-
fieldId === REGISTER_FIELD_IDS.CONFIRM_PASSWORD);
|
|
111
|
-
|
|
112
|
-
const inputElement = isPasswordField ? (
|
|
113
|
-
<PasswordField
|
|
114
|
-
inputId={fieldDefinition.id}
|
|
115
|
-
ariaLabel={fieldDefinition.ariaLabel}
|
|
116
|
-
value={fieldValue}
|
|
117
|
-
placeholder={fieldDefinition.placeholder}
|
|
118
|
-
autoComplete={fieldDefinition.autoComplete}
|
|
119
|
-
isVisible={formState.passwordVisibility[fieldDefinition.id as "password" | "confirm_password"]}
|
|
120
|
-
onChange={(nextValue) => formState.handleFieldChange(fieldId, nextValue)}
|
|
121
|
-
onToggleVisibility={() =>
|
|
122
|
-
formState.togglePasswordVisibility(fieldDefinition.id as "password" | "confirm_password")
|
|
123
|
-
}
|
|
124
|
-
errorMessage={fieldError as string | string[] | undefined}
|
|
125
|
-
/>
|
|
126
|
-
) : (
|
|
127
|
-
<Input
|
|
128
|
-
id={fieldDefinition.id}
|
|
129
|
-
type={fieldDefinition.type}
|
|
130
|
-
value={fieldValue}
|
|
131
|
-
onChange={(event) =>
|
|
132
|
-
formState.handleFieldChange(fieldId, event.target.value)
|
|
133
|
-
}
|
|
134
|
-
onBlur={
|
|
135
|
-
fieldId === REGISTER_FIELD_IDS.EMAIL
|
|
136
|
-
? formState.handleEmailBlur
|
|
137
|
-
: undefined
|
|
138
|
-
}
|
|
139
|
-
autoComplete={fieldDefinition.autoComplete}
|
|
140
|
-
placeholder={fieldDefinition.placeholder}
|
|
141
|
-
aria-label={fieldDefinition.ariaLabel}
|
|
142
|
-
className="cls_register_layout_field_input"
|
|
143
|
-
/>
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
// Only show email error if field has been touched (blurred)
|
|
147
|
-
const shouldShowError =
|
|
148
|
-
isPasswordField
|
|
149
|
-
? undefined
|
|
150
|
-
: fieldId === REGISTER_FIELD_IDS.EMAIL
|
|
151
|
-
? formState.emailTouched && fieldError
|
|
152
|
-
? fieldError
|
|
153
|
-
: undefined
|
|
154
|
-
: fieldError;
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<FormFieldWrapper
|
|
158
|
-
key={fieldId}
|
|
159
|
-
fieldId={fieldDefinition.id}
|
|
160
|
-
label={fieldDefinition.label}
|
|
161
|
-
input={inputElement}
|
|
162
|
-
errorMessage={shouldShowError}
|
|
163
|
-
/>
|
|
164
|
-
);
|
|
165
|
-
});
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
return (
|
|
169
|
-
<AlreadyLoggedInGuard
|
|
170
|
-
image_src={image_src}
|
|
171
|
-
image_alt={image_alt}
|
|
172
|
-
image_background_color={image_background_color}
|
|
173
|
-
message={alreadyLoggedInMessage}
|
|
174
|
-
showLogoutButton={showLogoutButton}
|
|
175
|
-
showReturnHomeButton={showReturnHomeButton}
|
|
176
|
-
returnHomeButtonLabel={returnHomeButtonLabel}
|
|
177
|
-
returnHomePath={returnHomePath}
|
|
178
|
-
>
|
|
179
|
-
<TwoColumnAuthLayout
|
|
180
|
-
imageSrc={image_src}
|
|
181
|
-
imageAlt={image_alt}
|
|
182
|
-
imageBackgroundColor={image_background_color}
|
|
183
|
-
formContent={
|
|
184
|
-
<>
|
|
185
|
-
<FormHeader
|
|
186
|
-
heading={resolvedLabels.heading}
|
|
187
|
-
subHeading={resolvedLabels.subHeading}
|
|
188
|
-
/>
|
|
189
|
-
<form
|
|
190
|
-
className="cls_register_layout_form_fields flex flex-col gap-5"
|
|
191
|
-
onSubmit={form.handleSubmit}
|
|
192
|
-
aria-label="Registration form"
|
|
193
|
-
>
|
|
194
|
-
{renderFields(form)}
|
|
195
|
-
<FormActionButtons
|
|
196
|
-
submitLabel={resolvedLabels.submitButton}
|
|
197
|
-
cancelLabel={resolvedLabels.cancelButton}
|
|
198
|
-
buttonPalette={resolvedButtonPalette}
|
|
199
|
-
isSubmitDisabled={form.isSubmitDisabled}
|
|
200
|
-
onCancel={form.handleCancel}
|
|
201
|
-
submitAriaLabel="Submit registration form"
|
|
202
|
-
cancelAriaLabel="Cancel registration form"
|
|
203
|
-
/>
|
|
204
|
-
<div className="cls_register_layout_sign_in_link flex items-center justify-center gap-1 text-sm text-muted-foreground">
|
|
205
|
-
<span>Already have an account?</span>
|
|
206
|
-
<Link
|
|
207
|
-
href={signInPath}
|
|
208
|
-
className="cls_register_layout_sign_in_link_text text-primary underline-offset-4 hover:underline"
|
|
209
|
-
aria-label="Go to sign in page"
|
|
210
|
-
>
|
|
211
|
-
{signInLabel}
|
|
212
|
-
</Link>
|
|
213
|
-
</div>
|
|
214
|
-
{form.isSubmitting && (
|
|
215
|
-
<div className="cls_register_submitting_indicator text-sm text-slate-600 text-center">
|
|
216
|
-
Registering...
|
|
217
|
-
</div>
|
|
218
|
-
)}
|
|
219
|
-
</form>
|
|
220
|
-
</>
|
|
221
|
-
}
|
|
222
|
-
/>
|
|
223
|
-
</AlreadyLoggedInGuard>
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// file_description: reset password layout specific configuration helpers
|
|
2
|
-
// section: imports
|
|
3
|
-
import type { LayoutFieldMap, LayoutFieldMapOverrides } from "hazo_auth/components/layouts/shared/config/layout_customization";
|
|
4
|
-
import {
|
|
5
|
-
resolveButtonPalette,
|
|
6
|
-
resolveFieldDefinitions,
|
|
7
|
-
resolveLabels,
|
|
8
|
-
type ButtonPaletteDefaults,
|
|
9
|
-
type ButtonPaletteOverrides,
|
|
10
|
-
type LayoutLabelDefaults,
|
|
11
|
-
type LayoutLabelOverrides,
|
|
12
|
-
type PasswordRequirementOptions,
|
|
13
|
-
type PasswordRequirementOverrides,
|
|
14
|
-
resolvePasswordRequirements,
|
|
15
|
-
} from "hazo_auth/components/layouts/shared/config/layout_customization";
|
|
16
|
-
|
|
17
|
-
// section: field_identifiers
|
|
18
|
-
export const RESET_PASSWORD_FIELD_IDS = {
|
|
19
|
-
PASSWORD: "password",
|
|
20
|
-
CONFIRM_PASSWORD: "confirm_password",
|
|
21
|
-
} as const;
|
|
22
|
-
|
|
23
|
-
export type ResetPasswordFieldId = (typeof RESET_PASSWORD_FIELD_IDS)[keyof typeof RESET_PASSWORD_FIELD_IDS];
|
|
24
|
-
|
|
25
|
-
// section: field_definitions
|
|
26
|
-
const RESET_PASSWORD_FIELD_DEFINITIONS: LayoutFieldMap = {
|
|
27
|
-
[RESET_PASSWORD_FIELD_IDS.PASSWORD]: {
|
|
28
|
-
id: RESET_PASSWORD_FIELD_IDS.PASSWORD,
|
|
29
|
-
label: "New password",
|
|
30
|
-
type: "password",
|
|
31
|
-
autoComplete: "new-password",
|
|
32
|
-
placeholder: "Enter your new password",
|
|
33
|
-
ariaLabel: "New password input field",
|
|
34
|
-
},
|
|
35
|
-
[RESET_PASSWORD_FIELD_IDS.CONFIRM_PASSWORD]: {
|
|
36
|
-
id: RESET_PASSWORD_FIELD_IDS.CONFIRM_PASSWORD,
|
|
37
|
-
label: "Confirm new password",
|
|
38
|
-
type: "password",
|
|
39
|
-
autoComplete: "new-password",
|
|
40
|
-
placeholder: "Re-enter your new password",
|
|
41
|
-
ariaLabel: "Confirm new password input field",
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const createResetPasswordFieldDefinitions = (
|
|
46
|
-
overrides?: LayoutFieldMapOverrides,
|
|
47
|
-
) => resolveFieldDefinitions(RESET_PASSWORD_FIELD_DEFINITIONS, overrides);
|
|
48
|
-
|
|
49
|
-
// section: label_defaults
|
|
50
|
-
const RESET_PASSWORD_LABEL_DEFAULTS: LayoutLabelDefaults = {
|
|
51
|
-
heading: "Reset your password",
|
|
52
|
-
subHeading: "Enter your new password below.",
|
|
53
|
-
submitButton: "Reset password",
|
|
54
|
-
cancelButton: "Cancel",
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const resolveResetPasswordLabels = (overrides?: LayoutLabelOverrides) =>
|
|
58
|
-
resolveLabels(RESET_PASSWORD_LABEL_DEFAULTS, overrides);
|
|
59
|
-
|
|
60
|
-
// section: button_palette_defaults
|
|
61
|
-
const RESET_PASSWORD_BUTTON_PALETTE_DEFAULTS: ButtonPaletteDefaults = {
|
|
62
|
-
submitBackground: "#0f172a",
|
|
63
|
-
submitText: "#ffffff",
|
|
64
|
-
cancelBorder: "#cbd5f5",
|
|
65
|
-
cancelText: "#0f172a",
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export const resolveResetPasswordButtonPalette = (overrides?: ButtonPaletteOverrides) =>
|
|
69
|
-
resolveButtonPalette(RESET_PASSWORD_BUTTON_PALETTE_DEFAULTS, overrides);
|
|
70
|
-
|
|
71
|
-
// section: password_requirements_defaults
|
|
72
|
-
const RESET_PASSWORD_PASSWORD_REQUIREMENT_DEFAULTS: PasswordRequirementOptions = {
|
|
73
|
-
minimum_length: 8,
|
|
74
|
-
require_uppercase: false,
|
|
75
|
-
require_lowercase: false,
|
|
76
|
-
require_number: false,
|
|
77
|
-
require_special: false,
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export const resolveResetPasswordPasswordRequirements = (
|
|
81
|
-
overrides?: PasswordRequirementOverrides,
|
|
82
|
-
) => resolvePasswordRequirements(RESET_PASSWORD_PASSWORD_REQUIREMENT_DEFAULTS, overrides);
|
|
83
|
-
|
|
84
|
-
// section: already_logged_in_label
|
|
85
|
-
export const RESET_PASSWORD_ALREADY_LOGGED_IN_MESSAGE_DEFAULT = "You're already logged in.";
|
|
86
|
-
|