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
package/src/app/layout.tsx
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// file_description: define the root layout wrapper for the hazo_auth project
|
|
2
|
-
import type { Metadata } from "next";
|
|
3
|
-
import local_font from "next/font/local";
|
|
4
|
-
import { Toaster } from "../components/ui/sonner";
|
|
5
|
-
import "./globals.css";
|
|
6
|
-
|
|
7
|
-
// section: typography_setup
|
|
8
|
-
const geist_sans = local_font({
|
|
9
|
-
src: "./fonts/GeistVF.woff",
|
|
10
|
-
variable: "--font-geist-sans",
|
|
11
|
-
weight: "100 900",
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const geist_mono = local_font({
|
|
15
|
-
src: "./fonts/GeistMonoVF.woff",
|
|
16
|
-
variable: "--font-geist-mono",
|
|
17
|
-
weight: "100 900",
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// section: metadata_definition
|
|
21
|
-
export const metadata: Metadata = {
|
|
22
|
-
title: "hazo reusable ui components",
|
|
23
|
-
description:
|
|
24
|
-
"Storybook-ready Next.js workspace for building reusable components powered by shadcn.",
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// section: root_layout_component
|
|
28
|
-
export default function root_layout({
|
|
29
|
-
children,
|
|
30
|
-
}: Readonly<{
|
|
31
|
-
children: React.ReactNode;
|
|
32
|
-
}>) {
|
|
33
|
-
return (
|
|
34
|
-
<html lang="en">
|
|
35
|
-
<body
|
|
36
|
-
className={`${geist_sans.variable} ${geist_mono.variable} antialiased`}
|
|
37
|
-
>
|
|
38
|
-
{children}
|
|
39
|
-
<Toaster />
|
|
40
|
-
</body>
|
|
41
|
-
</html>
|
|
42
|
-
);
|
|
43
|
-
}
|
package/src/app/page.tsx
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
// file_description: render the default landing page with sidebar navigation to test components
|
|
2
|
-
// section: client_directive
|
|
3
|
-
"use client";
|
|
4
|
-
|
|
5
|
-
// section: imports
|
|
6
|
-
import Link from "next/link";
|
|
7
|
-
import {
|
|
8
|
-
Sidebar,
|
|
9
|
-
SidebarContent,
|
|
10
|
-
SidebarGroup,
|
|
11
|
-
SidebarGroupLabel,
|
|
12
|
-
SidebarHeader,
|
|
13
|
-
SidebarMenu,
|
|
14
|
-
SidebarMenuButton,
|
|
15
|
-
SidebarMenuItem,
|
|
16
|
-
SidebarProvider,
|
|
17
|
-
SidebarTrigger,
|
|
18
|
-
SidebarInset,
|
|
19
|
-
} from "../components/ui/sidebar";
|
|
20
|
-
import { LogIn, UserPlus, BookOpen, ExternalLink, Database, KeyRound, MailCheck } from "lucide-react";
|
|
21
|
-
|
|
22
|
-
// section: page_component
|
|
23
|
-
export default function home_page() {
|
|
24
|
-
return (
|
|
25
|
-
<SidebarProvider>
|
|
26
|
-
<div className="cls_home_wrapper flex min-h-screen w-full">
|
|
27
|
-
<Sidebar>
|
|
28
|
-
<SidebarHeader className="cls_home_sidebar_header">
|
|
29
|
-
<div className="cls_home_sidebar_title flex items-center gap-2 px-2 py-4">
|
|
30
|
-
<h1 className="cls_home_sidebar_title_text text-lg font-semibold text-sidebar-foreground">
|
|
31
|
-
hazo auth
|
|
32
|
-
</h1>
|
|
33
|
-
</div>
|
|
34
|
-
</SidebarHeader>
|
|
35
|
-
<SidebarContent className="cls_home_sidebar_content">
|
|
36
|
-
<SidebarGroup className="cls_home_sidebar_test_group">
|
|
37
|
-
<SidebarGroupLabel className="cls_home_sidebar_group_label">
|
|
38
|
-
Test components
|
|
39
|
-
</SidebarGroupLabel>
|
|
40
|
-
<SidebarMenu className="cls_home_sidebar_test_menu">
|
|
41
|
-
<SidebarMenuItem className="cls_home_sidebar_test_login_item">
|
|
42
|
-
<SidebarMenuButton asChild>
|
|
43
|
-
<Link
|
|
44
|
-
href="/hazo_auth/login"
|
|
45
|
-
className="cls_home_sidebar_test_login_link flex items-center gap-2"
|
|
46
|
-
aria-label="Test login layout component"
|
|
47
|
-
>
|
|
48
|
-
<LogIn className="h-4 w-4" aria-hidden="true" />
|
|
49
|
-
<span>Test login</span>
|
|
50
|
-
</Link>
|
|
51
|
-
</SidebarMenuButton>
|
|
52
|
-
</SidebarMenuItem>
|
|
53
|
-
<SidebarMenuItem className="cls_home_sidebar_test_register_item">
|
|
54
|
-
<SidebarMenuButton asChild>
|
|
55
|
-
<Link
|
|
56
|
-
href="/hazo_auth/register"
|
|
57
|
-
className="cls_home_sidebar_test_register_link flex items-center gap-2"
|
|
58
|
-
aria-label="Test register layout component"
|
|
59
|
-
>
|
|
60
|
-
<UserPlus className="h-4 w-4" aria-hidden="true" />
|
|
61
|
-
<span>Test register</span>
|
|
62
|
-
</Link>
|
|
63
|
-
</SidebarMenuButton>
|
|
64
|
-
</SidebarMenuItem>
|
|
65
|
-
<SidebarMenuItem className="cls_home_sidebar_test_forgot_password_item">
|
|
66
|
-
<SidebarMenuButton asChild>
|
|
67
|
-
<Link
|
|
68
|
-
href="/hazo_auth/forgot_password"
|
|
69
|
-
className="cls_home_sidebar_test_forgot_password_link flex items-center gap-2"
|
|
70
|
-
aria-label="Test forgot password layout component"
|
|
71
|
-
>
|
|
72
|
-
<KeyRound className="h-4 w-4" aria-hidden="true" />
|
|
73
|
-
<span>Test forgot password</span>
|
|
74
|
-
</Link>
|
|
75
|
-
</SidebarMenuButton>
|
|
76
|
-
</SidebarMenuItem>
|
|
77
|
-
<SidebarMenuItem className="cls_home_sidebar_test_email_verification_item">
|
|
78
|
-
<SidebarMenuButton asChild>
|
|
79
|
-
<Link
|
|
80
|
-
href="/hazo_auth/verify_email"
|
|
81
|
-
className="cls_home_sidebar_test_email_verification_link flex items-center gap-2"
|
|
82
|
-
aria-label="Test email verification layout component"
|
|
83
|
-
>
|
|
84
|
-
<MailCheck className="h-4 w-4" aria-hidden="true" />
|
|
85
|
-
<span>Test email verification</span>
|
|
86
|
-
</Link>
|
|
87
|
-
</SidebarMenuButton>
|
|
88
|
-
</SidebarMenuItem>
|
|
89
|
-
<SidebarMenuItem className="cls_home_sidebar_sqlite_admin_item">
|
|
90
|
-
<SidebarMenuButton asChild>
|
|
91
|
-
<Link
|
|
92
|
-
href="/hazo_connect/sqlite_admin"
|
|
93
|
-
className="cls_home_sidebar_sqlite_admin_link flex items-center gap-2"
|
|
94
|
-
aria-label="Open SQLite admin UI to browse and edit database"
|
|
95
|
-
>
|
|
96
|
-
<Database className="h-4 w-4" aria-hidden="true" />
|
|
97
|
-
<span>SQLite Admin</span>
|
|
98
|
-
</Link>
|
|
99
|
-
</SidebarMenuButton>
|
|
100
|
-
</SidebarMenuItem>
|
|
101
|
-
</SidebarMenu>
|
|
102
|
-
</SidebarGroup>
|
|
103
|
-
<SidebarGroup className="cls_home_sidebar_resources_group">
|
|
104
|
-
<SidebarGroupLabel className="cls_home_sidebar_group_label">
|
|
105
|
-
Resources
|
|
106
|
-
</SidebarGroupLabel>
|
|
107
|
-
<SidebarMenu className="cls_home_sidebar_resources_menu">
|
|
108
|
-
<SidebarMenuItem className="cls_home_sidebar_storybook_item">
|
|
109
|
-
<SidebarMenuButton asChild>
|
|
110
|
-
<a
|
|
111
|
-
href="http://localhost:6006"
|
|
112
|
-
target="_blank"
|
|
113
|
-
rel="noopener noreferrer"
|
|
114
|
-
className="cls_home_sidebar_storybook_link flex items-center gap-2"
|
|
115
|
-
aria-label="Open Storybook preview for reusable components"
|
|
116
|
-
>
|
|
117
|
-
<BookOpen className="h-4 w-4" aria-hidden="true" />
|
|
118
|
-
<span>Storybook</span>
|
|
119
|
-
<ExternalLink className="ml-auto h-3 w-3" aria-hidden="true" />
|
|
120
|
-
</a>
|
|
121
|
-
</SidebarMenuButton>
|
|
122
|
-
</SidebarMenuItem>
|
|
123
|
-
<SidebarMenuItem className="cls_home_sidebar_docs_item">
|
|
124
|
-
<SidebarMenuButton asChild>
|
|
125
|
-
<a
|
|
126
|
-
href="https://ui.shadcn.com/docs"
|
|
127
|
-
target="_blank"
|
|
128
|
-
rel="noopener noreferrer"
|
|
129
|
-
className="cls_home_sidebar_docs_link flex items-center gap-2"
|
|
130
|
-
aria-label="Review shadcn documentation for styling guidance"
|
|
131
|
-
>
|
|
132
|
-
<BookOpen className="h-4 w-4" aria-hidden="true" />
|
|
133
|
-
<span>Shadcn docs</span>
|
|
134
|
-
<ExternalLink className="ml-auto h-3 w-3" aria-hidden="true" />
|
|
135
|
-
</a>
|
|
136
|
-
</SidebarMenuButton>
|
|
137
|
-
</SidebarMenuItem>
|
|
138
|
-
</SidebarMenu>
|
|
139
|
-
</SidebarGroup>
|
|
140
|
-
</SidebarContent>
|
|
141
|
-
</Sidebar>
|
|
142
|
-
<SidebarInset className="cls_home_sidebar_inset">
|
|
143
|
-
<header className="cls_home_main_header flex h-16 shrink-0 items-center gap-2 border-b px-4">
|
|
144
|
-
<SidebarTrigger className="cls_home_sidebar_trigger" />
|
|
145
|
-
<div className="cls_home_main_header_content flex flex-1 items-center gap-2">
|
|
146
|
-
<h2 className="cls_home_main_title text-lg font-semibold text-foreground">
|
|
147
|
-
hazo reusable ui library workspace
|
|
148
|
-
</h2>
|
|
149
|
-
</div>
|
|
150
|
-
</header>
|
|
151
|
-
<main className="cls_home_main_content flex flex-1 flex-col items-center justify-center gap-6 p-8 text-center">
|
|
152
|
-
<div className="cls_home_welcome_content flex w-full max-w-3xl flex-col items-center justify-center gap-6">
|
|
153
|
-
<h1 className="cls_home_welcome_title text-3xl font-semibold tracking-tight text-foreground md:text-4xl">
|
|
154
|
-
Welcome to hazo auth
|
|
155
|
-
</h1>
|
|
156
|
-
<p className="cls_home_welcome_summary text-base leading-relaxed text-muted-foreground md:text-lg">
|
|
157
|
-
Start shaping accessible, shadcn-powered components with integrated
|
|
158
|
-
hazo_config and hazo_connect support. Storybook is pre-installed so
|
|
159
|
-
you can document and iterate on each piece with confidence.
|
|
160
|
-
</p>
|
|
161
|
-
<p className="cls_home_welcome_instruction text-sm text-muted-foreground">
|
|
162
|
-
Use the sidebar to navigate to test components or access resources.
|
|
163
|
-
</p>
|
|
164
|
-
</div>
|
|
165
|
-
</main>
|
|
166
|
-
</SidebarInset>
|
|
167
|
-
</div>
|
|
168
|
-
</SidebarProvider>
|
|
169
|
-
);
|
|
170
|
-
}
|
package/src/components/index.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// file_description: email verification 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
|
-
} from "hazo_auth/components/layouts/shared/config/layout_customization";
|
|
13
|
-
|
|
14
|
-
// section: field_identifiers
|
|
15
|
-
export const EMAIL_VERIFICATION_FIELD_IDS = {
|
|
16
|
-
EMAIL: "email_address",
|
|
17
|
-
} as const;
|
|
18
|
-
|
|
19
|
-
export type EmailVerificationFieldId = (typeof EMAIL_VERIFICATION_FIELD_IDS)[keyof typeof EMAIL_VERIFICATION_FIELD_IDS];
|
|
20
|
-
|
|
21
|
-
// section: field_definitions
|
|
22
|
-
const EMAIL_VERIFICATION_FIELD_DEFINITIONS: LayoutFieldMap = {
|
|
23
|
-
[EMAIL_VERIFICATION_FIELD_IDS.EMAIL]: {
|
|
24
|
-
id: EMAIL_VERIFICATION_FIELD_IDS.EMAIL,
|
|
25
|
-
label: "Email address",
|
|
26
|
-
type: "email",
|
|
27
|
-
autoComplete: "email",
|
|
28
|
-
placeholder: "Enter your email address",
|
|
29
|
-
ariaLabel: "Email address input field",
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const createEmailVerificationFieldDefinitions = (
|
|
34
|
-
overrides?: LayoutFieldMapOverrides,
|
|
35
|
-
) => resolveFieldDefinitions(EMAIL_VERIFICATION_FIELD_DEFINITIONS, overrides);
|
|
36
|
-
|
|
37
|
-
// section: label_defaults
|
|
38
|
-
const EMAIL_VERIFICATION_LABEL_DEFAULTS: LayoutLabelDefaults = {
|
|
39
|
-
heading: "Email verification",
|
|
40
|
-
subHeading: "Verifying your email address...",
|
|
41
|
-
submitButton: "Resend verification email",
|
|
42
|
-
cancelButton: "Cancel",
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const resolveEmailVerificationLabels = (overrides?: LayoutLabelOverrides) =>
|
|
46
|
-
resolveLabels(EMAIL_VERIFICATION_LABEL_DEFAULTS, overrides);
|
|
47
|
-
|
|
48
|
-
// section: button_palette_defaults
|
|
49
|
-
const EMAIL_VERIFICATION_BUTTON_PALETTE_DEFAULTS: ButtonPaletteDefaults = {
|
|
50
|
-
submitBackground: "#0f172a",
|
|
51
|
-
submitText: "#ffffff",
|
|
52
|
-
cancelBorder: "#cbd5f5",
|
|
53
|
-
cancelText: "#0f172a",
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const resolveEmailVerificationButtonPalette = (overrides?: ButtonPaletteOverrides) =>
|
|
57
|
-
resolveButtonPalette(EMAIL_VERIFICATION_BUTTON_PALETTE_DEFAULTS, overrides);
|
|
58
|
-
|
|
59
|
-
// section: success_labels
|
|
60
|
-
export type EmailVerificationSuccessLabels = {
|
|
61
|
-
heading: string;
|
|
62
|
-
message: string;
|
|
63
|
-
redirectMessage: string;
|
|
64
|
-
goToLoginButton: string;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const EMAIL_VERIFICATION_SUCCESS_LABEL_DEFAULTS: EmailVerificationSuccessLabels = {
|
|
68
|
-
heading: "Email verified successfully",
|
|
69
|
-
message: "Your email address has been verified. You can now log in to your account.",
|
|
70
|
-
redirectMessage: "Redirecting to login page in",
|
|
71
|
-
goToLoginButton: "Go to login",
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
// section: error_labels
|
|
75
|
-
export type EmailVerificationErrorLabels = {
|
|
76
|
-
heading: string;
|
|
77
|
-
message: string;
|
|
78
|
-
resendFormHeading: string;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const EMAIL_VERIFICATION_ERROR_LABEL_DEFAULTS: EmailVerificationErrorLabels = {
|
|
82
|
-
heading: "Verification failed",
|
|
83
|
-
message: "The verification link is invalid or has expired.",
|
|
84
|
-
resendFormHeading: "Resend verification email",
|
|
85
|
-
};
|
|
86
|
-
|
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
// file_description: encapsulate email verification state, validation, and data interactions
|
|
2
|
-
// section: imports
|
|
3
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
4
|
-
import { useRouter, useSearchParams } from "next/navigation";
|
|
5
|
-
import { toast } from "sonner";
|
|
6
|
-
import type { LayoutDataClient } from "hazo_auth/components/layouts/shared/data/layout_data_client";
|
|
7
|
-
import { EMAIL_VERIFICATION_FIELD_IDS, type EmailVerificationFieldId } from "hazo_auth/components/layouts/email_verification/config/email_verification_field_config";
|
|
8
|
-
import { validateEmail } from "hazo_auth/components/layouts/shared/utils/validation";
|
|
9
|
-
|
|
10
|
-
// section: types
|
|
11
|
-
export type EmailVerificationFormValues = Record<EmailVerificationFieldId, string>;
|
|
12
|
-
export type EmailVerificationFormErrors = Partial<Record<EmailVerificationFieldId, string>> & {
|
|
13
|
-
submit?: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type UseEmailVerificationParams<TClient = unknown> = {
|
|
17
|
-
dataClient: LayoutDataClient<TClient>;
|
|
18
|
-
redirectDelay?: number; // Delay in seconds before redirecting to login
|
|
19
|
-
loginPath?: string; // Path to redirect to after successful verification
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type UseEmailVerificationResult = {
|
|
23
|
-
isVerifying: boolean;
|
|
24
|
-
isVerified: boolean;
|
|
25
|
-
isError: boolean;
|
|
26
|
-
errorMessage?: string;
|
|
27
|
-
email?: string; // Email from token if available
|
|
28
|
-
values: EmailVerificationFormValues;
|
|
29
|
-
errors: EmailVerificationFormErrors;
|
|
30
|
-
isSubmitDisabled: boolean;
|
|
31
|
-
isSubmitting: boolean;
|
|
32
|
-
emailTouched: boolean;
|
|
33
|
-
redirectCountdown: number;
|
|
34
|
-
handleFieldChange: (fieldId: EmailVerificationFieldId, value: string) => void;
|
|
35
|
-
handleEmailBlur: () => void;
|
|
36
|
-
handleResendSubmit: (event: React.FormEvent<HTMLFormElement>) => void;
|
|
37
|
-
handleCancel: () => void;
|
|
38
|
-
handleGoToLogin: () => void;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// section: helpers
|
|
42
|
-
const buildInitialValues = (initialEmail?: string): EmailVerificationFormValues => ({
|
|
43
|
-
[EMAIL_VERIFICATION_FIELD_IDS.EMAIL]: initialEmail || "",
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// section: hook
|
|
47
|
-
export const use_email_verification = <TClient,>({
|
|
48
|
-
dataClient,
|
|
49
|
-
redirectDelay = 5,
|
|
50
|
-
loginPath = "/hazo_auth/login",
|
|
51
|
-
}: UseEmailVerificationParams<TClient>): UseEmailVerificationResult => {
|
|
52
|
-
const router = useRouter();
|
|
53
|
-
const searchParams = useSearchParams();
|
|
54
|
-
const token = searchParams.get("token");
|
|
55
|
-
const emailParam = searchParams.get("email");
|
|
56
|
-
const messageParam = searchParams.get("message");
|
|
57
|
-
|
|
58
|
-
const [isVerifying, setIsVerifying] = useState<boolean>(false);
|
|
59
|
-
const [isVerified, setIsVerified] = useState<boolean>(false);
|
|
60
|
-
const [isError, setIsError] = useState<boolean>(false);
|
|
61
|
-
const [errorMessage, setErrorMessage] = useState<string | undefined>(messageParam || undefined);
|
|
62
|
-
const [email, setEmail] = useState<string | undefined>(emailParam || undefined);
|
|
63
|
-
const [values, setValues] = useState<EmailVerificationFormValues>(buildInitialValues(emailParam || undefined));
|
|
64
|
-
const [errors, setErrors] = useState<EmailVerificationFormErrors>({});
|
|
65
|
-
const [emailTouched, setEmailTouched] = useState<boolean>(false);
|
|
66
|
-
const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
|
|
67
|
-
const [redirectCountdown, setRedirectCountdown] = useState<number>(redirectDelay);
|
|
68
|
-
|
|
69
|
-
// Verify token on mount if token exists, or show error if message is provided
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
// If message is provided (from login redirect), show error state immediately
|
|
72
|
-
if (messageParam && !token) {
|
|
73
|
-
setIsError(true);
|
|
74
|
-
setErrorMessage(messageParam);
|
|
75
|
-
if (emailParam) {
|
|
76
|
-
setEmail(emailParam);
|
|
77
|
-
setValues(buildInitialValues(emailParam));
|
|
78
|
-
}
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (!token) {
|
|
83
|
-
setIsError(true);
|
|
84
|
-
setErrorMessage("No verification token provided");
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const verifyToken = async () => {
|
|
89
|
-
setIsVerifying(true);
|
|
90
|
-
setIsError(false);
|
|
91
|
-
setErrorMessage(undefined);
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
const response = await fetch(`/api/hazo_auth/verify_email?token=${encodeURIComponent(token)}`, {
|
|
95
|
-
method: "GET",
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
const data = await response.json();
|
|
99
|
-
|
|
100
|
-
if (!response.ok) {
|
|
101
|
-
throw new Error(data.error || "Email verification failed");
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Success
|
|
105
|
-
setIsVerified(true);
|
|
106
|
-
setEmail(data.email);
|
|
107
|
-
setValues(buildInitialValues(data.email));
|
|
108
|
-
|
|
109
|
-
// Start countdown for redirect
|
|
110
|
-
let countdown = redirectDelay;
|
|
111
|
-
setRedirectCountdown(countdown);
|
|
112
|
-
|
|
113
|
-
const countdownInterval = setInterval(() => {
|
|
114
|
-
countdown -= 1;
|
|
115
|
-
setRedirectCountdown(countdown);
|
|
116
|
-
|
|
117
|
-
if (countdown <= 0) {
|
|
118
|
-
clearInterval(countdownInterval);
|
|
119
|
-
router.push(loginPath);
|
|
120
|
-
}
|
|
121
|
-
}, 1000);
|
|
122
|
-
|
|
123
|
-
// Cleanup interval on unmount
|
|
124
|
-
return () => clearInterval(countdownInterval);
|
|
125
|
-
} catch (error) {
|
|
126
|
-
const errorMessage =
|
|
127
|
-
error instanceof Error ? error.message : "Email verification failed. Please try again.";
|
|
128
|
-
|
|
129
|
-
setIsError(true);
|
|
130
|
-
setErrorMessage(errorMessage);
|
|
131
|
-
|
|
132
|
-
// Try to extract email from error response if available
|
|
133
|
-
try {
|
|
134
|
-
const response = await fetch(`/api/hazo_auth/verify_email?token=${encodeURIComponent(token)}`, {
|
|
135
|
-
method: "GET",
|
|
136
|
-
});
|
|
137
|
-
const data = await response.json();
|
|
138
|
-
if (data.email) {
|
|
139
|
-
setEmail(data.email);
|
|
140
|
-
setValues(buildInitialValues(data.email));
|
|
141
|
-
}
|
|
142
|
-
} catch {
|
|
143
|
-
// Ignore errors when trying to get email
|
|
144
|
-
}
|
|
145
|
-
} finally {
|
|
146
|
-
setIsVerifying(false);
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
void verifyToken();
|
|
151
|
-
}, [token, redirectDelay, loginPath, router]);
|
|
152
|
-
|
|
153
|
-
const isSubmitDisabled = useMemo(() => {
|
|
154
|
-
if (isSubmitting) {
|
|
155
|
-
return true;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Only disable if there are active errors
|
|
159
|
-
const hasErrors = !!errors[EMAIL_VERIFICATION_FIELD_IDS.EMAIL];
|
|
160
|
-
return hasErrors;
|
|
161
|
-
}, [errors, isSubmitting]);
|
|
162
|
-
|
|
163
|
-
const handleFieldChange = useCallback((fieldId: EmailVerificationFieldId, value: string) => {
|
|
164
|
-
setValues((previousValues) => {
|
|
165
|
-
const nextValues: EmailVerificationFormValues = {
|
|
166
|
-
...previousValues,
|
|
167
|
-
[fieldId]: value,
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
setErrors((previousErrors) => {
|
|
171
|
-
const updatedErrors: EmailVerificationFormErrors = { ...previousErrors };
|
|
172
|
-
|
|
173
|
-
// Only validate email on change if it has been touched (blurred)
|
|
174
|
-
if (fieldId === EMAIL_VERIFICATION_FIELD_IDS.EMAIL && emailTouched) {
|
|
175
|
-
const emailError = validateEmail(value);
|
|
176
|
-
if (emailError) {
|
|
177
|
-
updatedErrors[EMAIL_VERIFICATION_FIELD_IDS.EMAIL] = emailError;
|
|
178
|
-
} else {
|
|
179
|
-
delete updatedErrors[EMAIL_VERIFICATION_FIELD_IDS.EMAIL];
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return updatedErrors;
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
return nextValues;
|
|
187
|
-
});
|
|
188
|
-
}, [emailTouched]);
|
|
189
|
-
|
|
190
|
-
const handleEmailBlur = useCallback(() => {
|
|
191
|
-
setEmailTouched(true);
|
|
192
|
-
// Validate email on blur
|
|
193
|
-
setErrors((previousErrors) => {
|
|
194
|
-
const updatedErrors: EmailVerificationFormErrors = { ...previousErrors };
|
|
195
|
-
const emailValue = values[EMAIL_VERIFICATION_FIELD_IDS.EMAIL];
|
|
196
|
-
const emailError = validateEmail(emailValue);
|
|
197
|
-
if (emailError) {
|
|
198
|
-
updatedErrors[EMAIL_VERIFICATION_FIELD_IDS.EMAIL] = emailError;
|
|
199
|
-
} else {
|
|
200
|
-
delete updatedErrors[EMAIL_VERIFICATION_FIELD_IDS.EMAIL];
|
|
201
|
-
}
|
|
202
|
-
return updatedErrors;
|
|
203
|
-
});
|
|
204
|
-
}, [values]);
|
|
205
|
-
|
|
206
|
-
const handleResendSubmit = useCallback(
|
|
207
|
-
async (event: React.FormEvent<HTMLFormElement>) => {
|
|
208
|
-
event.preventDefault();
|
|
209
|
-
|
|
210
|
-
// Final validation
|
|
211
|
-
const emailError = validateEmail(values[EMAIL_VERIFICATION_FIELD_IDS.EMAIL]);
|
|
212
|
-
|
|
213
|
-
if (emailError) {
|
|
214
|
-
setErrors({
|
|
215
|
-
[EMAIL_VERIFICATION_FIELD_IDS.EMAIL]: emailError,
|
|
216
|
-
});
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
setIsSubmitting(true);
|
|
221
|
-
setErrors({});
|
|
222
|
-
|
|
223
|
-
try {
|
|
224
|
-
const response = await fetch("/api/hazo_auth/resend_verification", {
|
|
225
|
-
method: "POST",
|
|
226
|
-
headers: {
|
|
227
|
-
"Content-Type": "application/json",
|
|
228
|
-
},
|
|
229
|
-
body: JSON.stringify({
|
|
230
|
-
email: values[EMAIL_VERIFICATION_FIELD_IDS.EMAIL],
|
|
231
|
-
}),
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
let data;
|
|
235
|
-
try {
|
|
236
|
-
data = await response.json();
|
|
237
|
-
} catch (jsonError) {
|
|
238
|
-
// If JSON parsing fails, the response is likely HTML (e.g., error page)
|
|
239
|
-
throw new Error("Server returned an invalid response. Please try again later.");
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (!response.ok) {
|
|
243
|
-
throw new Error(data.error || "Failed to resend verification email");
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// Show success notification
|
|
247
|
-
toast.success("Verification email sent", {
|
|
248
|
-
description: data.message || "If an account with that email exists and is not verified, a verification link has been sent.",
|
|
249
|
-
});
|
|
250
|
-
} catch (error) {
|
|
251
|
-
const errorMessage =
|
|
252
|
-
error instanceof Error ? error.message : "Failed to resend verification email. Please try again.";
|
|
253
|
-
|
|
254
|
-
// Show error notification
|
|
255
|
-
toast.error("Failed to resend verification email", {
|
|
256
|
-
description: errorMessage,
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
// Set error state
|
|
260
|
-
setErrors({
|
|
261
|
-
submit: errorMessage,
|
|
262
|
-
});
|
|
263
|
-
} finally {
|
|
264
|
-
setIsSubmitting(false);
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
[values, dataClient],
|
|
268
|
-
);
|
|
269
|
-
|
|
270
|
-
const handleCancel = useCallback(() => {
|
|
271
|
-
router.push(loginPath);
|
|
272
|
-
}, [router, loginPath]);
|
|
273
|
-
|
|
274
|
-
const handleGoToLogin = useCallback(() => {
|
|
275
|
-
router.push(loginPath);
|
|
276
|
-
}, [router, loginPath]);
|
|
277
|
-
|
|
278
|
-
return {
|
|
279
|
-
isVerifying,
|
|
280
|
-
isVerified,
|
|
281
|
-
isError,
|
|
282
|
-
errorMessage,
|
|
283
|
-
email,
|
|
284
|
-
values,
|
|
285
|
-
errors,
|
|
286
|
-
isSubmitDisabled,
|
|
287
|
-
isSubmitting,
|
|
288
|
-
emailTouched,
|
|
289
|
-
redirectCountdown,
|
|
290
|
-
handleFieldChange,
|
|
291
|
-
handleEmailBlur,
|
|
292
|
-
handleResendSubmit,
|
|
293
|
-
handleCancel,
|
|
294
|
-
handleGoToLogin,
|
|
295
|
-
};
|
|
296
|
-
};
|
|
297
|
-
|