hazo_auth 0.1.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.
Files changed (162) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -0
  3. package/components.json +22 -0
  4. package/hazo_auth_config.example.ini +414 -0
  5. package/hazo_notify_config.example.ini +159 -0
  6. package/instrumentation.ts +32 -0
  7. package/migrations/001_add_token_type_to_refresh_tokens.sql +14 -0
  8. package/migrations/002_add_name_to_hazo_users.sql +7 -0
  9. package/next.config.mjs +55 -0
  10. package/package.json +114 -0
  11. package/postcss.config.mjs +8 -0
  12. package/public/file.svg +1 -0
  13. package/public/globe.svg +1 -0
  14. package/public/next.svg +1 -0
  15. package/public/vercel.svg +1 -0
  16. package/public/window.svg +1 -0
  17. package/scripts/apply_migration.ts +118 -0
  18. package/src/app/api/auth/change_password/route.ts +109 -0
  19. package/src/app/api/auth/forgot_password/route.ts +107 -0
  20. package/src/app/api/auth/library_photos/route.ts +70 -0
  21. package/src/app/api/auth/login/route.ts +155 -0
  22. package/src/app/api/auth/logout/route.ts +62 -0
  23. package/src/app/api/auth/me/route.ts +47 -0
  24. package/src/app/api/auth/profile_picture/[filename]/route.ts +67 -0
  25. package/src/app/api/auth/register/route.ts +106 -0
  26. package/src/app/api/auth/remove_profile_picture/route.ts +86 -0
  27. package/src/app/api/auth/resend_verification/route.ts +107 -0
  28. package/src/app/api/auth/reset_password/route.ts +107 -0
  29. package/src/app/api/auth/update_user/route.ts +126 -0
  30. package/src/app/api/auth/upload_profile_picture/route.ts +268 -0
  31. package/src/app/api/auth/validate_reset_token/route.ts +80 -0
  32. package/src/app/api/auth/verify_email/route.ts +85 -0
  33. package/src/app/api/migrations/apply/route.ts +91 -0
  34. package/src/app/favicon.ico +0 -0
  35. package/src/app/fonts/GeistMonoVF.woff +0 -0
  36. package/src/app/fonts/GeistVF.woff +0 -0
  37. package/src/app/forgot_password/forgot_password_page_client.tsx +60 -0
  38. package/src/app/forgot_password/page.tsx +24 -0
  39. package/src/app/globals.css +89 -0
  40. package/src/app/hazo_connect/api/sqlite/data/route.ts +197 -0
  41. package/src/app/hazo_connect/api/sqlite/schema/route.ts +35 -0
  42. package/src/app/hazo_connect/api/sqlite/tables/route.ts +26 -0
  43. package/src/app/hazo_connect/sqlite_admin/page.tsx +51 -0
  44. package/src/app/hazo_connect/sqlite_admin/sqlite-admin-client.tsx +947 -0
  45. package/src/app/layout.tsx +43 -0
  46. package/src/app/login/login_page_client.tsx +71 -0
  47. package/src/app/login/page.tsx +26 -0
  48. package/src/app/my_settings/my_settings_page_client.tsx +120 -0
  49. package/src/app/my_settings/page.tsx +40 -0
  50. package/src/app/page.tsx +170 -0
  51. package/src/app/register/page.tsx +26 -0
  52. package/src/app/register/register_page_client.tsx +72 -0
  53. package/src/app/reset_password/page.tsx +29 -0
  54. package/src/app/reset_password/reset_password_page_client.tsx +81 -0
  55. package/src/app/verify_email/page.tsx +24 -0
  56. package/src/app/verify_email/verify_email_page_client.tsx +60 -0
  57. package/src/components/layouts/email_verification/config/email_verification_field_config.ts +86 -0
  58. package/src/components/layouts/email_verification/hooks/use_email_verification.ts +291 -0
  59. package/src/components/layouts/email_verification/index.tsx +297 -0
  60. package/src/components/layouts/forgot_password/config/forgot_password_field_config.ts +58 -0
  61. package/src/components/layouts/forgot_password/hooks/use_forgot_password_form.ts +179 -0
  62. package/src/components/layouts/forgot_password/index.tsx +168 -0
  63. package/src/components/layouts/login/config/login_field_config.ts +67 -0
  64. package/src/components/layouts/login/hooks/use_login_form.ts +281 -0
  65. package/src/components/layouts/login/index.tsx +224 -0
  66. package/src/components/layouts/my_settings/components/editable_field.tsx +177 -0
  67. package/src/components/layouts/my_settings/components/password_change_dialog.tsx +301 -0
  68. package/src/components/layouts/my_settings/components/profile_picture_dialog.tsx +385 -0
  69. package/src/components/layouts/my_settings/components/profile_picture_display.tsx +66 -0
  70. package/src/components/layouts/my_settings/components/profile_picture_gravatar_tab.tsx +143 -0
  71. package/src/components/layouts/my_settings/components/profile_picture_library_tab.tsx +282 -0
  72. package/src/components/layouts/my_settings/components/profile_picture_upload_tab.tsx +341 -0
  73. package/src/components/layouts/my_settings/config/my_settings_field_config.ts +61 -0
  74. package/src/components/layouts/my_settings/hooks/use_my_settings.ts +458 -0
  75. package/src/components/layouts/my_settings/index.tsx +351 -0
  76. package/src/components/layouts/register/config/register_field_config.ts +101 -0
  77. package/src/components/layouts/register/hooks/use_register_form.ts +272 -0
  78. package/src/components/layouts/register/index.tsx +208 -0
  79. package/src/components/layouts/reset_password/config/reset_password_field_config.ts +86 -0
  80. package/src/components/layouts/reset_password/hooks/use_reset_password_form.ts +276 -0
  81. package/src/components/layouts/reset_password/index.tsx +294 -0
  82. package/src/components/layouts/shared/components/already_logged_in_guard.tsx +95 -0
  83. package/src/components/layouts/shared/components/field_error_message.tsx +29 -0
  84. package/src/components/layouts/shared/components/form_action_buttons.tsx +64 -0
  85. package/src/components/layouts/shared/components/form_field_wrapper.tsx +44 -0
  86. package/src/components/layouts/shared/components/form_header.tsx +36 -0
  87. package/src/components/layouts/shared/components/logout_button.tsx +76 -0
  88. package/src/components/layouts/shared/components/password_field.tsx +72 -0
  89. package/src/components/layouts/shared/components/sidebar_layout_wrapper.tsx +264 -0
  90. package/src/components/layouts/shared/components/two_column_auth_layout.tsx +44 -0
  91. package/src/components/layouts/shared/components/unauthorized_guard.tsx +78 -0
  92. package/src/components/layouts/shared/components/visual_panel.tsx +41 -0
  93. package/src/components/layouts/shared/config/layout_customization.ts +95 -0
  94. package/src/components/layouts/shared/data/layout_data_client.ts +19 -0
  95. package/src/components/layouts/shared/hooks/use_auth_status.ts +103 -0
  96. package/src/components/layouts/shared/utils/ip_address.ts +37 -0
  97. package/src/components/layouts/shared/utils/validation.ts +66 -0
  98. package/src/components/ui/avatar.tsx +50 -0
  99. package/src/components/ui/button.tsx +57 -0
  100. package/src/components/ui/dialog.tsx +122 -0
  101. package/src/components/ui/hazo_ui_tooltip.tsx +67 -0
  102. package/src/components/ui/input.tsx +22 -0
  103. package/src/components/ui/label.tsx +26 -0
  104. package/src/components/ui/separator.tsx +31 -0
  105. package/src/components/ui/sheet.tsx +139 -0
  106. package/src/components/ui/sidebar.tsx +773 -0
  107. package/src/components/ui/skeleton.tsx +15 -0
  108. package/src/components/ui/sonner.tsx +31 -0
  109. package/src/components/ui/switch.tsx +29 -0
  110. package/src/components/ui/tabs.tsx +55 -0
  111. package/src/components/ui/tooltip.tsx +32 -0
  112. package/src/components/ui/vertical-tabs.tsx +59 -0
  113. package/src/hooks/use-mobile.tsx +19 -0
  114. package/src/lib/already_logged_in_config.server.ts +46 -0
  115. package/src/lib/app_logger.ts +24 -0
  116. package/src/lib/auth/auth_utils.server.ts +196 -0
  117. package/src/lib/auth/server_auth.ts +88 -0
  118. package/src/lib/config/config_loader.server.ts +149 -0
  119. package/src/lib/email_verification_config.server.ts +32 -0
  120. package/src/lib/file_types_config.server.ts +25 -0
  121. package/src/lib/forgot_password_config.server.ts +32 -0
  122. package/src/lib/hazo_connect_instance.server.ts +77 -0
  123. package/src/lib/hazo_connect_setup.server.ts +181 -0
  124. package/src/lib/hazo_connect_setup.ts +54 -0
  125. package/src/lib/login_config.server.ts +46 -0
  126. package/src/lib/messages_config.server.ts +45 -0
  127. package/src/lib/migrations/apply_migration.ts +105 -0
  128. package/src/lib/my_settings_config.server.ts +135 -0
  129. package/src/lib/password_requirements_config.server.ts +39 -0
  130. package/src/lib/profile_picture_config.server.ts +56 -0
  131. package/src/lib/register_config.server.ts +57 -0
  132. package/src/lib/reset_password_config.server.ts +75 -0
  133. package/src/lib/services/email_service.ts +581 -0
  134. package/src/lib/services/email_verification_service.ts +264 -0
  135. package/src/lib/services/login_service.ts +118 -0
  136. package/src/lib/services/password_change_service.ts +154 -0
  137. package/src/lib/services/password_reset_service.ts +405 -0
  138. package/src/lib/services/profile_picture_remove_service.ts +120 -0
  139. package/src/lib/services/profile_picture_service.ts +215 -0
  140. package/src/lib/services/profile_picture_source_mapper.ts +62 -0
  141. package/src/lib/services/registration_service.ts +163 -0
  142. package/src/lib/services/token_service.ts +240 -0
  143. package/src/lib/services/user_update_service.ts +128 -0
  144. package/src/lib/ui_sizes_config.server.ts +37 -0
  145. package/src/lib/user_fields_config.server.ts +31 -0
  146. package/src/lib/utils/api_route_helpers.ts +60 -0
  147. package/src/lib/utils.ts +11 -0
  148. package/src/middleware.ts +91 -0
  149. package/src/server/config/config_loader.ts +496 -0
  150. package/src/server/index.ts +38 -0
  151. package/src/server/logging/logger_service.ts +56 -0
  152. package/src/server/routes/root_router.ts +16 -0
  153. package/src/server/server.ts +28 -0
  154. package/src/server/types/app_types.ts +74 -0
  155. package/src/server/types/express.d.ts +15 -0
  156. package/src/stories/email_verification_layout.stories.tsx +137 -0
  157. package/src/stories/forgot_password_layout.stories.tsx +85 -0
  158. package/src/stories/login_layout.stories.tsx +85 -0
  159. package/src/stories/project_overview.stories.tsx +33 -0
  160. package/src/stories/register_layout.stories.tsx +107 -0
  161. package/tailwind.config.ts +77 -0
  162. package/tsconfig.json +27 -0
@@ -0,0 +1,351 @@
1
+ // file_description: my settings layout component with tabs for profile and security settings
2
+ // section: client_directive
3
+ "use client";
4
+
5
+ // section: imports
6
+ import { Button } from "@/components/ui/button";
7
+ import { EditableField } from "./components/editable_field";
8
+ import { ProfilePictureDisplay } from "./components/profile_picture_display";
9
+ import { ProfilePictureDialog } from "./components/profile_picture_dialog";
10
+ import { UnauthorizedGuard } from "@/components/layouts/shared/components/unauthorized_guard";
11
+ import { use_my_settings } from "./hooks/use_my_settings";
12
+ import {
13
+ resolveMySettingsLabels,
14
+ resolveMySettingsButtonPalette,
15
+ type MySettingsLabelOverrides,
16
+ } from "./config/my_settings_field_config";
17
+ import type {
18
+ PasswordRequirementOptions,
19
+ ButtonPaletteOverrides,
20
+ } from "@/components/layouts/shared/config/layout_customization";
21
+ import { formatDistanceToNow } from "date-fns";
22
+ import { PasswordField } from "@/components/layouts/shared/components/password_field";
23
+ import { FormFieldWrapper } from "@/components/layouts/shared/components/form_field_wrapper";
24
+ import { Pencil, Trash2 } from "lucide-react";
25
+
26
+ // section: types
27
+ export type MySettingsLayoutProps = {
28
+ labels?: MySettingsLabelOverrides;
29
+ button_colors?: ButtonPaletteOverrides;
30
+ password_requirements: PasswordRequirementOptions;
31
+ profilePicture: {
32
+ allow_photo_upload: boolean;
33
+ upload_photo_path?: string;
34
+ max_photo_size: number;
35
+ user_photo_default: boolean;
36
+ user_photo_default_priority1: "gravatar" | "library";
37
+ user_photo_default_priority2?: "library" | "gravatar";
38
+ library_photo_path: string;
39
+ };
40
+ userFields: {
41
+ show_name_field: boolean;
42
+ show_email_field: boolean;
43
+ show_password_field: boolean;
44
+ };
45
+ unauthorizedMessage?: string;
46
+ loginButtonLabel?: string;
47
+ loginPath?: string;
48
+ heading?: string;
49
+ subHeading?: string;
50
+ profilePhotoLabel?: string;
51
+ profilePhotoRecommendation?: string;
52
+ uploadPhotoButtonLabel?: string;
53
+ removePhotoButtonLabel?: string;
54
+ profileInformationLabel?: string;
55
+ passwordLabel?: string;
56
+ currentPasswordLabel?: string;
57
+ newPasswordLabel?: string;
58
+ confirmPasswordLabel?: string;
59
+ messages: {
60
+ photo_upload_disabled_message: string;
61
+ gravatar_setup_message: string;
62
+ gravatar_no_account_message: string;
63
+ library_tooltip_message: string;
64
+ };
65
+ uiSizes: {
66
+ gravatar_size: number;
67
+ profile_picture_size: number;
68
+ tooltip_icon_size_default: number;
69
+ tooltip_icon_size_small: number;
70
+ library_photo_grid_columns: number;
71
+ library_photo_preview_size: number;
72
+ image_compression_max_dimension: number;
73
+ upload_file_hard_limit_bytes: number;
74
+ };
75
+ fileTypes: {
76
+ allowed_image_extensions: string[];
77
+ allowed_image_mime_types: string[];
78
+ };
79
+ };
80
+
81
+ // section: component
82
+ /**
83
+ * My Settings layout component with tabs for profile and security settings
84
+ * Shows editable fields for name, email, and password change dialog
85
+ * Displays profile picture and last logged in information
86
+ * @param props - Component props including labels, button colors, password requirements, etc.
87
+ * @returns My settings layout component
88
+ */
89
+ export default function my_settings_layout({
90
+ labels,
91
+ button_colors,
92
+ password_requirements,
93
+ profilePicture,
94
+ userFields,
95
+ unauthorizedMessage = "You must be logged in to access this page.",
96
+ loginButtonLabel = "Go to login",
97
+ loginPath = "/login",
98
+ heading = "Account Settings",
99
+ subHeading = "Manage your profile, password, and email preferences.",
100
+ profilePhotoLabel = "Profile Photo",
101
+ profilePhotoRecommendation = "Recommended size: 200x200px. JPG, PNG.",
102
+ uploadPhotoButtonLabel = "Upload New Photo",
103
+ removePhotoButtonLabel = "Remove",
104
+ profileInformationLabel = "Profile Information",
105
+ passwordLabel = "Password",
106
+ currentPasswordLabel = "Current Password",
107
+ newPasswordLabel = "New Password",
108
+ confirmPasswordLabel = "Confirm Password",
109
+ messages,
110
+ uiSizes,
111
+ fileTypes,
112
+ }: MySettingsLayoutProps) {
113
+ const resolvedLabels = resolveMySettingsLabels(labels);
114
+ const resolvedButtonPalette = resolveMySettingsButtonPalette(button_colors);
115
+
116
+ const settings = use_my_settings({
117
+ passwordRequirements: password_requirements,
118
+ });
119
+
120
+ return (
121
+ <UnauthorizedGuard
122
+ message={unauthorizedMessage}
123
+ loginButtonLabel={loginButtonLabel}
124
+ loginPath={loginPath}
125
+ >
126
+ <div className="cls_my_settings_layout flex flex-col gap-6 p-6 max-w-4xl mx-auto min-h-screen bg-slate-50">
127
+ {/* Header Section */}
128
+ <div className="cls_my_settings_layout_header flex flex-col gap-2">
129
+ <h1 className="cls_my_settings_layout_heading text-3xl font-bold text-slate-900">
130
+ {heading}
131
+ </h1>
132
+ <p className="cls_my_settings_layout_subheading text-slate-600">
133
+ {subHeading}
134
+ </p>
135
+ </div>
136
+
137
+ {/* Profile Photo Section */}
138
+ <div className="cls_my_settings_layout_profile_photo_section bg-white rounded-lg border border-slate-200 p-6">
139
+ <h2 className="cls_my_settings_layout_section_heading text-lg font-semibold text-slate-900 mb-4">
140
+ {profilePhotoLabel}
141
+ </h2>
142
+ <div className="cls_my_settings_layout_profile_photo_content flex flex-col items-center">
143
+ <div className="cls_my_settings_layout_profile_photo_display relative">
144
+ <ProfilePictureDisplay
145
+ profilePictureUrl={settings.profilePictureUrl}
146
+ name={settings.name}
147
+ email={settings.email}
148
+ onEdit={settings.handleProfilePictureEdit}
149
+ />
150
+ <div className="cls_my_settings_layout_profile_photo_actions absolute left-0 right-0 flex items-center justify-between px-2" style={{ bottom: '-20px' }}>
151
+ <Button
152
+ type="button"
153
+ onClick={settings.handleProfilePictureEdit}
154
+ disabled={settings.loading}
155
+ variant="ghost"
156
+ size="icon"
157
+ className="cls_my_settings_layout_upload_photo_button"
158
+ aria-label={uploadPhotoButtonLabel}
159
+ >
160
+ <Pencil className="h-4 w-4" aria-hidden="true" />
161
+ </Button>
162
+ <Button
163
+ type="button"
164
+ onClick={settings.handleProfilePictureRemove}
165
+ disabled={settings.loading || !settings.profilePictureUrl}
166
+ variant="ghost"
167
+ size="icon"
168
+ className="cls_my_settings_layout_remove_photo_button text-red-600 hover:text-red-700 hover:bg-red-50"
169
+ aria-label={removePhotoButtonLabel}
170
+ >
171
+ <Trash2 className="h-4 w-4" aria-hidden="true" />
172
+ </Button>
173
+ </div>
174
+ </div>
175
+ </div>
176
+ </div>
177
+
178
+ {/* Profile Information Section */}
179
+ <div className="cls_my_settings_layout_profile_information_section bg-white rounded-lg border border-slate-200 p-6">
180
+ <h2 className="cls_my_settings_layout_section_heading text-lg font-semibold text-slate-900 mb-4">
181
+ {profileInformationLabel}
182
+ </h2>
183
+ <div className="cls_my_settings_layout_profile_information_fields grid grid-cols-1 md:grid-cols-2 gap-6">
184
+ {/* Name Field */}
185
+ {userFields.show_name_field && (
186
+ <EditableField
187
+ label="Full Name"
188
+ value={settings.name}
189
+ type="text"
190
+ placeholder="Enter your full name"
191
+ onSave={settings.handleNameSave}
192
+ validation={validateName}
193
+ disabled={settings.loading}
194
+ ariaLabel="Full name input field"
195
+ />
196
+ )}
197
+
198
+ {/* Email Field */}
199
+ {userFields.show_email_field && (
200
+ <EditableField
201
+ label="Email Address"
202
+ value={settings.email}
203
+ type="email"
204
+ placeholder="Enter your email address"
205
+ onSave={settings.handleEmailSave}
206
+ validation={validateEmail}
207
+ disabled={settings.loading}
208
+ ariaLabel="Email address input field"
209
+ />
210
+ )}
211
+ </div>
212
+ </div>
213
+
214
+ {/* Password Section */}
215
+ {userFields.show_password_field && (
216
+ <div className="cls_my_settings_layout_password_section bg-white rounded-lg border border-slate-200 p-6">
217
+ <h2 className="cls_my_settings_layout_section_heading text-lg font-semibold text-slate-900 mb-4">
218
+ {passwordLabel}
219
+ </h2>
220
+ <div className="cls_my_settings_layout_password_fields flex flex-col gap-6">
221
+ {/* Current Password Field - Full Width */}
222
+ <FormFieldWrapper
223
+ fieldId="current-password"
224
+ label={currentPasswordLabel}
225
+ input={
226
+ <PasswordField
227
+ inputId="current-password"
228
+ ariaLabel={currentPasswordLabel}
229
+ value={settings.passwordFields?.currentPassword || ""}
230
+ placeholder="Enter your current password"
231
+ autoComplete="current-password"
232
+ isVisible={settings.passwordFields?.currentPasswordVisible || false}
233
+ onChange={(value) => settings.handlePasswordFieldChange("currentPassword", value)}
234
+ onToggleVisibility={() => settings.togglePasswordVisibility("currentPassword")}
235
+ errorMessage={settings.passwordFields?.errors?.currentPassword}
236
+ />
237
+ }
238
+ />
239
+
240
+ {/* New Password and Confirm Password Fields - Side by Side */}
241
+ <div className="cls_my_settings_layout_password_fields_row grid grid-cols-1 md:grid-cols-2 gap-6">
242
+ {/* New Password Field */}
243
+ <FormFieldWrapper
244
+ fieldId="new-password"
245
+ label={newPasswordLabel}
246
+ input={
247
+ <PasswordField
248
+ inputId="new-password"
249
+ ariaLabel={newPasswordLabel}
250
+ value={settings.passwordFields?.newPassword || ""}
251
+ placeholder="Enter your new password"
252
+ autoComplete="new-password"
253
+ isVisible={settings.passwordFields?.newPasswordVisible || false}
254
+ onChange={(value) => settings.handlePasswordFieldChange("newPassword", value)}
255
+ onToggleVisibility={() => settings.togglePasswordVisibility("newPassword")}
256
+ errorMessage={settings.passwordFields?.errors?.newPassword}
257
+ />
258
+ }
259
+ />
260
+
261
+ {/* Confirm Password Field */}
262
+ <FormFieldWrapper
263
+ fieldId="confirm-password"
264
+ label={confirmPasswordLabel}
265
+ input={
266
+ <PasswordField
267
+ inputId="confirm-password"
268
+ ariaLabel={confirmPasswordLabel}
269
+ value={settings.passwordFields?.confirmPassword || ""}
270
+ placeholder="Confirm your new password"
271
+ autoComplete="new-password"
272
+ isVisible={settings.passwordFields?.confirmPasswordVisible || false}
273
+ onChange={(value) => settings.handlePasswordFieldChange("confirmPassword", value)}
274
+ onToggleVisibility={() => settings.togglePasswordVisibility("confirmPassword")}
275
+ errorMessage={settings.passwordFields?.errors?.confirmPassword}
276
+ />
277
+ }
278
+ />
279
+ </div>
280
+ </div>
281
+ {/* Save Password Button */}
282
+ <div className="cls_my_settings_layout_password_actions flex justify-end mt-4">
283
+ <Button
284
+ type="button"
285
+ onClick={settings.handlePasswordSave}
286
+ disabled={settings.loading || settings.isPasswordSaveDisabled}
287
+ className="cls_my_settings_layout_save_password_button"
288
+ style={{
289
+ backgroundColor: resolvedButtonPalette.submitBackground,
290
+ color: resolvedButtonPalette.submitText,
291
+ }}
292
+ aria-label="Save password"
293
+ >
294
+ Save Password
295
+ </Button>
296
+ </div>
297
+ </div>
298
+ )}
299
+
300
+ {/* Profile Picture Dialog */}
301
+ <ProfilePictureDialog
302
+ open={settings.profilePictureDialogOpen}
303
+ onOpenChange={(open) => {
304
+ if (open) {
305
+ settings.handleProfilePictureEdit();
306
+ } else {
307
+ settings.handleProfilePictureDialogClose();
308
+ }
309
+ }}
310
+ onSave={settings.handleProfilePictureSave}
311
+ email={settings.email}
312
+ allowPhotoUpload={profilePicture.allow_photo_upload}
313
+ maxPhotoSize={profilePicture.max_photo_size}
314
+ libraryPhotoPath={profilePicture.library_photo_path}
315
+ currentProfilePictureUrl={settings.profilePictureUrl}
316
+ currentProfileSource={settings.profileSource}
317
+ disabled={settings.loading}
318
+ messages={messages}
319
+ uiSizes={uiSizes}
320
+ fileTypes={fileTypes}
321
+ />
322
+ </div>
323
+ </UnauthorizedGuard>
324
+ );
325
+ }
326
+
327
+ // section: validation_helpers
328
+ /**
329
+ * Validates name (optional, but if provided should not be empty)
330
+ */
331
+ function validateName(name: string): string | null {
332
+ if (name.trim() === "") {
333
+ return "Name cannot be empty";
334
+ }
335
+ return null;
336
+ }
337
+
338
+ /**
339
+ * Validates email format
340
+ */
341
+ function validateEmail(email: string): string | null {
342
+ if (!email || email.trim() === "") {
343
+ return "Email is required";
344
+ }
345
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
346
+ if (!emailRegex.test(email)) {
347
+ return "Invalid email address format";
348
+ }
349
+ return null;
350
+ }
351
+
@@ -0,0 +1,101 @@
1
+ // file_description: register layout specific configuration helpers
2
+ // section: imports
3
+ import type { LayoutFieldMap, LayoutFieldMapOverrides } from "@/components/layouts/shared/config/layout_customization";
4
+ import {
5
+ resolveButtonPalette,
6
+ resolveFieldDefinitions,
7
+ resolveLabels,
8
+ resolvePasswordRequirements,
9
+ type ButtonPaletteDefaults,
10
+ type ButtonPaletteOverrides,
11
+ type LayoutLabelDefaults,
12
+ type LayoutLabelOverrides,
13
+ type PasswordRequirementOptions,
14
+ type PasswordRequirementOverrides,
15
+ } from "@/components/layouts/shared/config/layout_customization";
16
+
17
+ // section: field_identifiers
18
+ export const REGISTER_FIELD_IDS = {
19
+ NAME: "name",
20
+ EMAIL: "email_address",
21
+ PASSWORD: "password",
22
+ CONFIRM_PASSWORD: "confirm_password",
23
+ } as const;
24
+
25
+ export type RegisterFieldId = (typeof REGISTER_FIELD_IDS)[keyof typeof REGISTER_FIELD_IDS];
26
+
27
+ // section: field_definitions
28
+ const REGISTER_FIELD_DEFINITIONS: LayoutFieldMap = {
29
+ [REGISTER_FIELD_IDS.NAME]: {
30
+ id: REGISTER_FIELD_IDS.NAME,
31
+ label: "Full name",
32
+ type: "text",
33
+ autoComplete: "name",
34
+ placeholder: "Enter your full name",
35
+ ariaLabel: "Full name input field",
36
+ },
37
+ [REGISTER_FIELD_IDS.EMAIL]: {
38
+ id: REGISTER_FIELD_IDS.EMAIL,
39
+ label: "Email address",
40
+ type: "email",
41
+ autoComplete: "email",
42
+ placeholder: "Enter your email address",
43
+ ariaLabel: "Email address input field",
44
+ },
45
+ [REGISTER_FIELD_IDS.PASSWORD]: {
46
+ id: REGISTER_FIELD_IDS.PASSWORD,
47
+ label: "Password",
48
+ type: "password",
49
+ autoComplete: "new-password",
50
+ placeholder: "Enter your password",
51
+ ariaLabel: "Password input field",
52
+ },
53
+ [REGISTER_FIELD_IDS.CONFIRM_PASSWORD]: {
54
+ id: REGISTER_FIELD_IDS.CONFIRM_PASSWORD,
55
+ label: "Re-enter password",
56
+ type: "password",
57
+ autoComplete: "new-password",
58
+ placeholder: "Re-enter your password",
59
+ ariaLabel: "Re-enter password input field",
60
+ },
61
+ };
62
+
63
+ export const createRegisterFieldDefinitions = (
64
+ overrides?: LayoutFieldMapOverrides,
65
+ ) => resolveFieldDefinitions(REGISTER_FIELD_DEFINITIONS, overrides);
66
+
67
+ // section: label_defaults
68
+ const REGISTER_LABEL_DEFAULTS: LayoutLabelDefaults = {
69
+ heading: "Create your hazo account",
70
+ subHeading: "Secure your access with editable fields powered by shadcn components.",
71
+ submitButton: "Register",
72
+ cancelButton: "Cancel",
73
+ };
74
+
75
+ export const resolveRegisterLabels = (overrides?: LayoutLabelOverrides) =>
76
+ resolveLabels(REGISTER_LABEL_DEFAULTS, overrides);
77
+
78
+ // section: button_palette_defaults
79
+ const REGISTER_BUTTON_PALETTE_DEFAULTS: ButtonPaletteDefaults = {
80
+ submitBackground: "#0f172a",
81
+ submitText: "#ffffff",
82
+ cancelBorder: "#cbd5f5",
83
+ cancelText: "#0f172a",
84
+ };
85
+
86
+ export const resolveRegisterButtonPalette = (overrides?: ButtonPaletteOverrides) =>
87
+ resolveButtonPalette(REGISTER_BUTTON_PALETTE_DEFAULTS, overrides);
88
+
89
+ // section: password_rules
90
+ const REGISTER_PASSWORD_REQUIREMENTS: PasswordRequirementOptions = {
91
+ minimum_length: 8,
92
+ require_uppercase: true,
93
+ require_lowercase: true,
94
+ require_number: true,
95
+ require_special: true,
96
+ };
97
+
98
+ export const resolveRegisterPasswordRequirements = (
99
+ overrides?: PasswordRequirementOverrides,
100
+ ) => resolvePasswordRequirements(REGISTER_PASSWORD_REQUIREMENTS, overrides);
101
+