hazo_auth 1.4.2 → 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/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/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/hooks/use-mobile.d.ts.map +1 -1
- package/dist/hooks/use-mobile.js +17 -3
- 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/package.json +12 -17
- 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 -36
- package/tsconfig.json +0 -28
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
// file_description: shared sidebar layout wrapper for auth pages to ensure consistent navigation
|
|
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 "../../../ui/sidebar";
|
|
20
|
-
import { LogIn, UserPlus, BookOpen, ExternalLink, Database, KeyRound, MailCheck, Key, Settings, User } from "lucide-react";
|
|
21
|
-
import { use_auth_status } from "../hooks/use_auth_status";
|
|
22
|
-
import { ProfilePicMenu } from "./profile_pic_menu";
|
|
23
|
-
|
|
24
|
-
// section: types
|
|
25
|
-
type SidebarLayoutWrapperProps = {
|
|
26
|
-
children: React.ReactNode;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
// section: component
|
|
30
|
-
export function SidebarLayoutWrapper({ children }: SidebarLayoutWrapperProps) {
|
|
31
|
-
const authStatus = use_auth_status();
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<SidebarProvider>
|
|
35
|
-
<div className="cls_sidebar_layout_wrapper flex min-h-screen w-full">
|
|
36
|
-
<Sidebar>
|
|
37
|
-
<SidebarHeader className="cls_sidebar_layout_header">
|
|
38
|
-
<div className="cls_sidebar_layout_title flex items-center gap-2 px-2 py-4">
|
|
39
|
-
<h1 className="cls_sidebar_layout_title_text text-lg font-semibold text-sidebar-foreground">
|
|
40
|
-
hazo auth
|
|
41
|
-
</h1>
|
|
42
|
-
</div>
|
|
43
|
-
</SidebarHeader>
|
|
44
|
-
<SidebarContent className="cls_sidebar_layout_content">
|
|
45
|
-
<SidebarGroup className="cls_sidebar_layout_test_group">
|
|
46
|
-
<SidebarGroupLabel className="cls_sidebar_layout_group_label">
|
|
47
|
-
Test components
|
|
48
|
-
</SidebarGroupLabel>
|
|
49
|
-
<SidebarMenu className="cls_sidebar_layout_test_menu">
|
|
50
|
-
<SidebarMenuItem className="cls_sidebar_layout_test_login_item">
|
|
51
|
-
<SidebarMenuButton asChild>
|
|
52
|
-
<Link
|
|
53
|
-
href="/hazo_auth/login"
|
|
54
|
-
className="cls_sidebar_layout_test_login_link flex items-center gap-2"
|
|
55
|
-
aria-label="Test login layout component"
|
|
56
|
-
>
|
|
57
|
-
<LogIn className="h-4 w-4" aria-hidden="true" />
|
|
58
|
-
<span>Test login</span>
|
|
59
|
-
</Link>
|
|
60
|
-
</SidebarMenuButton>
|
|
61
|
-
</SidebarMenuItem>
|
|
62
|
-
<SidebarMenuItem className="cls_sidebar_layout_test_register_item">
|
|
63
|
-
<SidebarMenuButton asChild>
|
|
64
|
-
<Link
|
|
65
|
-
href="/hazo_auth/register"
|
|
66
|
-
className="cls_sidebar_layout_test_register_link flex items-center gap-2"
|
|
67
|
-
aria-label="Test register layout component"
|
|
68
|
-
>
|
|
69
|
-
<UserPlus className="h-4 w-4" aria-hidden="true" />
|
|
70
|
-
<span>Test register</span>
|
|
71
|
-
</Link>
|
|
72
|
-
</SidebarMenuButton>
|
|
73
|
-
</SidebarMenuItem>
|
|
74
|
-
<SidebarMenuItem className="cls_sidebar_layout_test_forgot_password_item">
|
|
75
|
-
<SidebarMenuButton asChild>
|
|
76
|
-
<Link
|
|
77
|
-
href="/hazo_auth/forgot_password"
|
|
78
|
-
className="cls_sidebar_layout_test_forgot_password_link flex items-center gap-2"
|
|
79
|
-
aria-label="Test forgot password layout component"
|
|
80
|
-
>
|
|
81
|
-
<KeyRound className="h-4 w-4" aria-hidden="true" />
|
|
82
|
-
<span>Test forgot password</span>
|
|
83
|
-
</Link>
|
|
84
|
-
</SidebarMenuButton>
|
|
85
|
-
</SidebarMenuItem>
|
|
86
|
-
<SidebarMenuItem className="cls_sidebar_layout_test_reset_password_item">
|
|
87
|
-
<SidebarMenuButton asChild>
|
|
88
|
-
<Link
|
|
89
|
-
href="/hazo_auth/reset_password"
|
|
90
|
-
className="cls_sidebar_layout_test_reset_password_link flex items-center gap-2"
|
|
91
|
-
aria-label="Test reset password layout component"
|
|
92
|
-
>
|
|
93
|
-
<Key className="h-4 w-4" aria-hidden="true" />
|
|
94
|
-
<span>Test reset password</span>
|
|
95
|
-
</Link>
|
|
96
|
-
</SidebarMenuButton>
|
|
97
|
-
</SidebarMenuItem>
|
|
98
|
-
<SidebarMenuItem className="cls_sidebar_layout_test_email_verification_item">
|
|
99
|
-
<SidebarMenuButton asChild>
|
|
100
|
-
<Link
|
|
101
|
-
href="/hazo_auth/verify_email"
|
|
102
|
-
className="cls_sidebar_layout_test_email_verification_link flex items-center gap-2"
|
|
103
|
-
aria-label="Test email verification layout component"
|
|
104
|
-
>
|
|
105
|
-
<MailCheck className="h-4 w-4" aria-hidden="true" />
|
|
106
|
-
<span>Test email verification</span>
|
|
107
|
-
</Link>
|
|
108
|
-
</SidebarMenuButton>
|
|
109
|
-
</SidebarMenuItem>
|
|
110
|
-
<SidebarMenuItem className="cls_sidebar_layout_sqlite_admin_item">
|
|
111
|
-
<SidebarMenuButton asChild>
|
|
112
|
-
<Link
|
|
113
|
-
href="/hazo_connect/sqlite_admin"
|
|
114
|
-
className="cls_sidebar_layout_sqlite_admin_link flex items-center gap-2"
|
|
115
|
-
aria-label="Open SQLite admin UI to browse and edit database"
|
|
116
|
-
>
|
|
117
|
-
<Database className="h-4 w-4" aria-hidden="true" />
|
|
118
|
-
<span>SQLite Admin</span>
|
|
119
|
-
</Link>
|
|
120
|
-
</SidebarMenuButton>
|
|
121
|
-
</SidebarMenuItem>
|
|
122
|
-
<SidebarMenuItem className="cls_sidebar_layout_user_management_item">
|
|
123
|
-
<SidebarMenuButton asChild>
|
|
124
|
-
<Link
|
|
125
|
-
href="/hazo_auth/user_management"
|
|
126
|
-
className="cls_sidebar_layout_user_management_link flex items-center gap-2"
|
|
127
|
-
aria-label="Open User Management to manage users, roles, and permissions"
|
|
128
|
-
>
|
|
129
|
-
<User className="h-4 w-4" aria-hidden="true" />
|
|
130
|
-
<span>User Management</span>
|
|
131
|
-
</Link>
|
|
132
|
-
</SidebarMenuButton>
|
|
133
|
-
</SidebarMenuItem>
|
|
134
|
-
</SidebarMenu>
|
|
135
|
-
</SidebarGroup>
|
|
136
|
-
{authStatus.authenticated && (
|
|
137
|
-
<SidebarGroup className="cls_sidebar_layout_account_group">
|
|
138
|
-
<SidebarGroupLabel className="cls_sidebar_layout_group_label">
|
|
139
|
-
Account
|
|
140
|
-
</SidebarGroupLabel>
|
|
141
|
-
<SidebarMenu className="cls_sidebar_layout_account_menu">
|
|
142
|
-
<SidebarMenuItem className="cls_sidebar_layout_my_settings_item">
|
|
143
|
-
<SidebarMenuButton asChild>
|
|
144
|
-
<Link
|
|
145
|
-
href="/hazo_auth/my_settings"
|
|
146
|
-
className="cls_sidebar_layout_my_settings_link flex items-center gap-2"
|
|
147
|
-
aria-label="Open my settings page"
|
|
148
|
-
>
|
|
149
|
-
<Settings className="h-4 w-4" aria-hidden="true" />
|
|
150
|
-
<span>My Settings</span>
|
|
151
|
-
</Link>
|
|
152
|
-
</SidebarMenuButton>
|
|
153
|
-
</SidebarMenuItem>
|
|
154
|
-
</SidebarMenu>
|
|
155
|
-
</SidebarGroup>
|
|
156
|
-
)}
|
|
157
|
-
<SidebarGroup className="cls_sidebar_layout_resources_group">
|
|
158
|
-
<SidebarGroupLabel className="cls_sidebar_layout_group_label">
|
|
159
|
-
Resources
|
|
160
|
-
</SidebarGroupLabel>
|
|
161
|
-
<SidebarMenu className="cls_sidebar_layout_resources_menu">
|
|
162
|
-
<SidebarMenuItem className="cls_sidebar_layout_storybook_item">
|
|
163
|
-
<SidebarMenuButton asChild>
|
|
164
|
-
<a
|
|
165
|
-
href="http://localhost:6006"
|
|
166
|
-
target="_blank"
|
|
167
|
-
rel="noopener noreferrer"
|
|
168
|
-
className="cls_sidebar_layout_storybook_link flex items-center gap-2"
|
|
169
|
-
aria-label="Open Storybook preview for reusable components"
|
|
170
|
-
>
|
|
171
|
-
<BookOpen className="h-4 w-4" aria-hidden="true" />
|
|
172
|
-
<span>Storybook</span>
|
|
173
|
-
<ExternalLink className="ml-auto h-3 w-3" aria-hidden="true" />
|
|
174
|
-
</a>
|
|
175
|
-
</SidebarMenuButton>
|
|
176
|
-
</SidebarMenuItem>
|
|
177
|
-
<SidebarMenuItem className="cls_sidebar_layout_docs_item">
|
|
178
|
-
<SidebarMenuButton asChild>
|
|
179
|
-
<a
|
|
180
|
-
href="https://ui.shadcn.com/docs"
|
|
181
|
-
target="_blank"
|
|
182
|
-
rel="noopener noreferrer"
|
|
183
|
-
className="cls_sidebar_layout_docs_link flex items-center gap-2"
|
|
184
|
-
aria-label="Review shadcn documentation for styling guidance"
|
|
185
|
-
>
|
|
186
|
-
<BookOpen className="h-4 w-4" aria-hidden="true" />
|
|
187
|
-
<span>Shadcn docs</span>
|
|
188
|
-
<ExternalLink className="ml-auto h-3 w-3" aria-hidden="true" />
|
|
189
|
-
</a>
|
|
190
|
-
</SidebarMenuButton>
|
|
191
|
-
</SidebarMenuItem>
|
|
192
|
-
</SidebarMenu>
|
|
193
|
-
</SidebarGroup>
|
|
194
|
-
</SidebarContent>
|
|
195
|
-
</Sidebar>
|
|
196
|
-
<SidebarInset className="cls_sidebar_layout_inset">
|
|
197
|
-
<header className="cls_sidebar_layout_main_header flex h-16 shrink-0 items-center gap-2 border-b px-4">
|
|
198
|
-
<SidebarTrigger className="cls_sidebar_layout_trigger" />
|
|
199
|
-
<div className="cls_sidebar_layout_main_header_content flex flex-1 items-center gap-2">
|
|
200
|
-
<h2 className="cls_sidebar_layout_main_title text-lg font-semibold text-foreground">
|
|
201
|
-
hazo reusable ui library workspace
|
|
202
|
-
</h2>
|
|
203
|
-
</div>
|
|
204
|
-
<ProfilePicMenu className="cls_sidebar_layout_auth_status" avatar_size="sm" />
|
|
205
|
-
</header>
|
|
206
|
-
<main className="cls_sidebar_layout_main_content flex flex-1 items-center justify-center p-6">
|
|
207
|
-
{children}
|
|
208
|
-
</main>
|
|
209
|
-
</SidebarInset>
|
|
210
|
-
</div>
|
|
211
|
-
</SidebarProvider>
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// file_description: renders a simple full-width shell without the developer sidebar
|
|
2
|
-
// section: client_directive
|
|
3
|
-
"use client";
|
|
4
|
-
|
|
5
|
-
// section: imports
|
|
6
|
-
import { cn } from "../../../../lib/utils";
|
|
7
|
-
|
|
8
|
-
// section: types
|
|
9
|
-
export type StandaloneLayoutWrapperProps = {
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
heading?: string;
|
|
12
|
-
description?: string;
|
|
13
|
-
wrapperClassName?: string;
|
|
14
|
-
contentClassName?: string;
|
|
15
|
-
showHeading?: boolean;
|
|
16
|
-
showDescription?: boolean;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// section: component
|
|
20
|
-
export function StandaloneLayoutWrapper({
|
|
21
|
-
children,
|
|
22
|
-
heading = "hazo auth",
|
|
23
|
-
description = "Drop-in authentication flows that inherit your existing theme.",
|
|
24
|
-
wrapperClassName,
|
|
25
|
-
contentClassName,
|
|
26
|
-
showHeading = true,
|
|
27
|
-
showDescription = true,
|
|
28
|
-
}: StandaloneLayoutWrapperProps) {
|
|
29
|
-
return (
|
|
30
|
-
<div className={cn("cls_standalone_layout_wrapper min-h-screen w-full bg-background", wrapperClassName)}>
|
|
31
|
-
<div className={cn("cls_standalone_layout_content mx-auto flex w-full max-w-5xl flex-col gap-8 p-6", contentClassName)}>
|
|
32
|
-
{(showHeading || showDescription) && (
|
|
33
|
-
<div className="cls_standalone_layout_header text-center">
|
|
34
|
-
{showHeading && (
|
|
35
|
-
<h1 className="cls_standalone_layout_title text-2xl font-semibold tracking-tight text-foreground">
|
|
36
|
-
{heading}
|
|
37
|
-
</h1>
|
|
38
|
-
)}
|
|
39
|
-
{showDescription && (
|
|
40
|
-
<p className="cls_standalone_layout_description mt-2 text-sm text-muted-foreground">
|
|
41
|
-
{description}
|
|
42
|
-
</p>
|
|
43
|
-
)}
|
|
44
|
-
</div>
|
|
45
|
-
)}
|
|
46
|
-
<div className="cls_standalone_layout_body">{children}</div>
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// file_description: reusable two-column authentication layout shell that combines visual panel and form content
|
|
2
|
-
// section: imports
|
|
3
|
-
import { VisualPanel } from "./visual_panel";
|
|
4
|
-
|
|
5
|
-
// section: types
|
|
6
|
-
type TwoColumnAuthLayoutProps = {
|
|
7
|
-
imageSrc: string;
|
|
8
|
-
imageAlt: string;
|
|
9
|
-
imageBackgroundColor?: string;
|
|
10
|
-
formContent: React.ReactNode;
|
|
11
|
-
className?: string;
|
|
12
|
-
visualPanelClassName?: string;
|
|
13
|
-
formContainerClassName?: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// section: component
|
|
17
|
-
export function TwoColumnAuthLayout({
|
|
18
|
-
imageSrc,
|
|
19
|
-
imageAlt,
|
|
20
|
-
imageBackgroundColor,
|
|
21
|
-
formContent,
|
|
22
|
-
className,
|
|
23
|
-
visualPanelClassName,
|
|
24
|
-
formContainerClassName,
|
|
25
|
-
}: TwoColumnAuthLayoutProps) {
|
|
26
|
-
return (
|
|
27
|
-
<div
|
|
28
|
-
className={`cls_two_column_auth_layout mx-auto grid w-full max-w-5xl grid-cols-1 overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm md:grid-cols-2 md:min-h-[520px] ${className ?? ""}`}
|
|
29
|
-
>
|
|
30
|
-
<VisualPanel
|
|
31
|
-
imageSrc={imageSrc}
|
|
32
|
-
imageAlt={imageAlt}
|
|
33
|
-
backgroundColor={imageBackgroundColor}
|
|
34
|
-
className={visualPanelClassName}
|
|
35
|
-
/>
|
|
36
|
-
<div
|
|
37
|
-
className={`cls_two_column_auth_layout_form_container flex flex-col gap-6 p-8 ${formContainerClassName ?? ""}`}
|
|
38
|
-
>
|
|
39
|
-
{formContent}
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// file_description: reusable component to show unauthorized message when user is not authenticated
|
|
2
|
-
// section: client_directive
|
|
3
|
-
"use client";
|
|
4
|
-
|
|
5
|
-
// section: imports
|
|
6
|
-
import { use_auth_status } from "../hooks/use_auth_status";
|
|
7
|
-
import { Button } from "../../../ui/button";
|
|
8
|
-
import { useRouter } from "next/navigation";
|
|
9
|
-
import { LogIn } from "lucide-react";
|
|
10
|
-
|
|
11
|
-
// section: types
|
|
12
|
-
export type UnauthorizedGuardProps = {
|
|
13
|
-
message?: string;
|
|
14
|
-
loginButtonLabel?: string;
|
|
15
|
-
loginPath?: string;
|
|
16
|
-
children: React.ReactNode;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// section: component
|
|
20
|
-
/**
|
|
21
|
-
* Guard component that shows unauthorized message if user is not authenticated
|
|
22
|
-
* Otherwise renders children
|
|
23
|
-
* @param props - Component props including message and login button customization
|
|
24
|
-
* @returns Either the unauthorized UI or the children
|
|
25
|
-
*/
|
|
26
|
-
export function UnauthorizedGuard({
|
|
27
|
-
message = "You must be logged in to access this page.",
|
|
28
|
-
loginButtonLabel = "Go to login",
|
|
29
|
-
loginPath = "/hazo_auth/login",
|
|
30
|
-
children,
|
|
31
|
-
}: UnauthorizedGuardProps) {
|
|
32
|
-
const router = useRouter();
|
|
33
|
-
const authStatus = use_auth_status();
|
|
34
|
-
|
|
35
|
-
// Check if user should see unauthorized message
|
|
36
|
-
const shouldShowUnauthorized = !authStatus.authenticated && !authStatus.loading;
|
|
37
|
-
|
|
38
|
-
if (shouldShowUnauthorized) {
|
|
39
|
-
return (
|
|
40
|
-
<div className="cls_unauthorized_guard flex flex-col items-center justify-center min-h-screen p-8">
|
|
41
|
-
<div className="cls_unauthorized_guard_content flex flex-col items-center gap-4 text-center max-w-md">
|
|
42
|
-
<div className="cls_unauthorized_guard_icon flex items-center justify-center w-16 h-16 rounded-full bg-red-100">
|
|
43
|
-
<LogIn className="h-8 w-8 text-red-600" aria-hidden="true" />
|
|
44
|
-
</div>
|
|
45
|
-
<div className="cls_unauthorized_guard_text">
|
|
46
|
-
<h1 className="cls_unauthorized_guard_heading text-2xl font-semibold text-slate-900 mb-2">
|
|
47
|
-
Access Denied
|
|
48
|
-
</h1>
|
|
49
|
-
<p className="cls_unauthorized_guard_message text-slate-600">
|
|
50
|
-
{message}
|
|
51
|
-
</p>
|
|
52
|
-
</div>
|
|
53
|
-
<Button
|
|
54
|
-
onClick={() => router.push(loginPath)}
|
|
55
|
-
variant="default"
|
|
56
|
-
className="cls_unauthorized_guard_login_button mt-4"
|
|
57
|
-
aria-label={loginButtonLabel}
|
|
58
|
-
>
|
|
59
|
-
<LogIn className="h-4 w-4 mr-2" aria-hidden="true" />
|
|
60
|
-
{loginButtonLabel}
|
|
61
|
-
</Button>
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Show loading state while checking authentication
|
|
68
|
-
if (authStatus.loading) {
|
|
69
|
-
return (
|
|
70
|
-
<div className="cls_unauthorized_guard_loading flex items-center justify-center min-h-screen">
|
|
71
|
-
<div className="cls_unauthorized_guard_loading_text text-slate-600">Loading...</div>
|
|
72
|
-
</div>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return <>{children}</>;
|
|
77
|
-
}
|
|
78
|
-
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// file_description: reusable visual panel component for displaying images in authentication layouts
|
|
2
|
-
// section: client_directive
|
|
3
|
-
"use client";
|
|
4
|
-
|
|
5
|
-
// section: imports
|
|
6
|
-
import Image from "next/image";
|
|
7
|
-
|
|
8
|
-
// section: types
|
|
9
|
-
type VisualPanelProps = {
|
|
10
|
-
imageSrc: string;
|
|
11
|
-
imageAlt: string;
|
|
12
|
-
backgroundColor?: string;
|
|
13
|
-
className?: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// section: component
|
|
17
|
-
export function VisualPanel({
|
|
18
|
-
imageSrc,
|
|
19
|
-
imageAlt,
|
|
20
|
-
backgroundColor = "#f1f5f9",
|
|
21
|
-
className,
|
|
22
|
-
}: VisualPanelProps) {
|
|
23
|
-
return (
|
|
24
|
-
<div
|
|
25
|
-
className={`cls_visual_panel relative hidden h-full w-full items-center justify-center md:flex ${className ?? ""}`}
|
|
26
|
-
style={{ backgroundColor }}
|
|
27
|
-
>
|
|
28
|
-
<div className="cls_visual_panel_image_wrapper relative h-full w-full">
|
|
29
|
-
<Image
|
|
30
|
-
src={imageSrc}
|
|
31
|
-
alt={imageAlt}
|
|
32
|
-
fill
|
|
33
|
-
sizes="(min-width: 768px) 50vw, 100vw"
|
|
34
|
-
className="cls_visual_panel_image object-cover"
|
|
35
|
-
priority
|
|
36
|
-
/>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
// file_description: provide reusable configuration helpers for layout components
|
|
2
|
-
// section: types
|
|
3
|
-
export type LayoutFieldId = string;
|
|
4
|
-
|
|
5
|
-
export type LayoutFieldDefinition = {
|
|
6
|
-
id: LayoutFieldId;
|
|
7
|
-
label: string;
|
|
8
|
-
type: "text" | "email" | "password";
|
|
9
|
-
autoComplete?: string;
|
|
10
|
-
placeholder: string;
|
|
11
|
-
ariaLabel: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export type LayoutFieldMap = Record<LayoutFieldId, LayoutFieldDefinition>;
|
|
15
|
-
export type LayoutFieldMapOverrides = Partial<Record<LayoutFieldId, Partial<LayoutFieldDefinition>>>;
|
|
16
|
-
|
|
17
|
-
export type LayoutLabelDefaults = {
|
|
18
|
-
heading: string;
|
|
19
|
-
subHeading: string;
|
|
20
|
-
submitButton: string;
|
|
21
|
-
cancelButton: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type LayoutLabelOverrides = Partial<LayoutLabelDefaults>;
|
|
25
|
-
|
|
26
|
-
export type ButtonPaletteDefaults = {
|
|
27
|
-
submitBackground: string;
|
|
28
|
-
submitText: string;
|
|
29
|
-
cancelBorder: string;
|
|
30
|
-
cancelText: string;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type ButtonPaletteOverrides = Partial<ButtonPaletteDefaults>;
|
|
34
|
-
|
|
35
|
-
export type PasswordRequirementOptions = {
|
|
36
|
-
minimum_length: number;
|
|
37
|
-
require_uppercase: boolean;
|
|
38
|
-
require_lowercase: boolean;
|
|
39
|
-
require_number: boolean;
|
|
40
|
-
require_special: boolean;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export type PasswordRequirementOverrides = Partial<PasswordRequirementOptions>;
|
|
44
|
-
|
|
45
|
-
// section: helpers
|
|
46
|
-
export const resolveFieldDefinitions = (
|
|
47
|
-
baseDefinitions: LayoutFieldMap,
|
|
48
|
-
overrides?: LayoutFieldMapOverrides,
|
|
49
|
-
): LayoutFieldMap => {
|
|
50
|
-
if (!overrides) {
|
|
51
|
-
return baseDefinitions;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const merged: LayoutFieldMap = { ...baseDefinitions };
|
|
55
|
-
|
|
56
|
-
Object.entries(overrides).forEach(([fieldId, definitionOverride]) => {
|
|
57
|
-
if (!definitionOverride) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const existing = merged[fieldId] ?? (definitionOverride as LayoutFieldDefinition);
|
|
62
|
-
merged[fieldId] = {
|
|
63
|
-
...existing,
|
|
64
|
-
...definitionOverride,
|
|
65
|
-
id: existing.id ?? (fieldId as LayoutFieldId),
|
|
66
|
-
};
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
return merged;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export const resolveLabels = (
|
|
73
|
-
defaults: LayoutLabelDefaults,
|
|
74
|
-
overrides?: LayoutLabelOverrides,
|
|
75
|
-
): LayoutLabelDefaults => ({
|
|
76
|
-
...defaults,
|
|
77
|
-
...(overrides ?? {}),
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
export const resolveButtonPalette = (
|
|
81
|
-
defaults: ButtonPaletteDefaults,
|
|
82
|
-
overrides?: ButtonPaletteOverrides,
|
|
83
|
-
): ButtonPaletteDefaults => ({
|
|
84
|
-
...defaults,
|
|
85
|
-
...(overrides ?? {}),
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
export const resolvePasswordRequirements = (
|
|
89
|
-
defaults: PasswordRequirementOptions,
|
|
90
|
-
overrides?: PasswordRequirementOverrides,
|
|
91
|
-
): PasswordRequirementOptions => ({
|
|
92
|
-
...defaults,
|
|
93
|
-
...(overrides ?? {}),
|
|
94
|
-
});
|
|
95
|
-
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// file_description: expose a common data client wrapper for layout components
|
|
2
|
-
// section: types
|
|
3
|
-
export type LayoutDataClient<TClient = unknown> = {
|
|
4
|
-
client: TClient;
|
|
5
|
-
healthCheck: () => Promise<void>;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
// section: factory
|
|
9
|
-
export const createLayoutDataClient = <TClient,>(
|
|
10
|
-
hazoClient: TClient,
|
|
11
|
-
): LayoutDataClient<TClient> => ({
|
|
12
|
-
client: hazoClient,
|
|
13
|
-
healthCheck: async () => {
|
|
14
|
-
if (hazoClient && typeof (hazoClient as Record<string, unknown>).healthCheck === "function") {
|
|
15
|
-
await ((hazoClient as unknown) as { healthCheck: () => Promise<void> }).healthCheck();
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
// file_description: hook to check authentication status and get current user info
|
|
2
|
-
// section: client_directive
|
|
3
|
-
"use client";
|
|
4
|
-
|
|
5
|
-
// section: imports
|
|
6
|
-
import { useState, useEffect, useCallback } from "react";
|
|
7
|
-
|
|
8
|
-
// section: types
|
|
9
|
-
export type AuthStatusData = {
|
|
10
|
-
authenticated: boolean;
|
|
11
|
-
user_id?: string;
|
|
12
|
-
email?: string;
|
|
13
|
-
name?: string;
|
|
14
|
-
email_verified?: boolean;
|
|
15
|
-
last_logon?: string;
|
|
16
|
-
profile_picture_url?: string;
|
|
17
|
-
profile_source?: "upload" | "library" | "gravatar" | "custom";
|
|
18
|
-
loading: boolean;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type AuthStatus = AuthStatusData & {
|
|
22
|
-
refresh: () => Promise<void>;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// section: constants
|
|
26
|
-
const AUTH_STATUS_CHANGE_EVENT = "hazo_auth_status_change";
|
|
27
|
-
|
|
28
|
-
// section: helpers
|
|
29
|
-
/**
|
|
30
|
-
* Dispatches a custom event to notify all auth status hooks to refresh
|
|
31
|
-
*/
|
|
32
|
-
export function trigger_auth_status_refresh(): void {
|
|
33
|
-
if (typeof window !== "undefined") {
|
|
34
|
-
window.dispatchEvent(new CustomEvent(AUTH_STATUS_CHANGE_EVENT));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// section: hook
|
|
39
|
-
export function use_auth_status(): AuthStatus {
|
|
40
|
-
const [authStatus, setAuthStatus] = useState<AuthStatusData>({
|
|
41
|
-
authenticated: false,
|
|
42
|
-
loading: true,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const checkAuth = useCallback(async () => {
|
|
46
|
-
setAuthStatus((prev) => ({ ...prev, loading: true }));
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
const response = await fetch("/api/hazo_auth/me", {
|
|
50
|
-
method: "GET",
|
|
51
|
-
credentials: "include",
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const data = await response.json();
|
|
55
|
-
|
|
56
|
-
if (data.authenticated) {
|
|
57
|
-
setAuthStatus({
|
|
58
|
-
authenticated: true,
|
|
59
|
-
user_id: data.user_id,
|
|
60
|
-
email: data.email,
|
|
61
|
-
name: data.name,
|
|
62
|
-
email_verified: data.email_verified,
|
|
63
|
-
last_logon: data.last_logon,
|
|
64
|
-
profile_picture_url: data.profile_picture_url,
|
|
65
|
-
profile_source: data.profile_source,
|
|
66
|
-
loading: false,
|
|
67
|
-
});
|
|
68
|
-
} else {
|
|
69
|
-
setAuthStatus({
|
|
70
|
-
authenticated: false,
|
|
71
|
-
loading: false,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
} catch (error) {
|
|
75
|
-
setAuthStatus({
|
|
76
|
-
authenticated: false,
|
|
77
|
-
loading: false,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}, []);
|
|
81
|
-
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
// Check auth status on mount
|
|
84
|
-
void checkAuth();
|
|
85
|
-
|
|
86
|
-
// Listen for auth status change events
|
|
87
|
-
const handleAuthChange = () => {
|
|
88
|
-
void checkAuth();
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
window.addEventListener(AUTH_STATUS_CHANGE_EVENT, handleAuthChange);
|
|
92
|
-
|
|
93
|
-
return () => {
|
|
94
|
-
window.removeEventListener(AUTH_STATUS_CHANGE_EVENT, handleAuthChange);
|
|
95
|
-
};
|
|
96
|
-
}, [checkAuth]);
|
|
97
|
-
|
|
98
|
-
return {
|
|
99
|
-
...authStatus,
|
|
100
|
-
refresh: checkAuth,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|