hazo_auth 1.0.4 → 1.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 (108) hide show
  1. package/README.md +72 -1
  2. package/hazo_auth_config.example.ini +41 -0
  3. package/instrumentation.ts +2 -2
  4. package/package.json +4 -3
  5. package/scripts/init_users.ts +378 -0
  6. package/src/app/api/hazo_auth/auth/upload_profile_picture/route.ts +8 -8
  7. package/src/app/api/hazo_auth/change_password/route.ts +7 -7
  8. package/src/app/api/hazo_auth/forgot_password/route.ts +4 -4
  9. package/src/app/api/hazo_auth/get_auth/route.ts +4 -4
  10. package/src/app/api/hazo_auth/invalidate_cache/route.ts +5 -5
  11. package/src/app/api/hazo_auth/library_photos/route.ts +3 -3
  12. package/src/app/api/hazo_auth/login/route.ts +31 -5
  13. package/src/app/api/hazo_auth/logout/route.ts +4 -4
  14. package/src/app/api/hazo_auth/me/route.ts +1 -1
  15. package/src/app/api/hazo_auth/profile_picture/[filename]/route.ts +1 -1
  16. package/src/app/api/hazo_auth/register/route.ts +17 -14
  17. package/src/app/api/hazo_auth/remove_profile_picture/route.ts +5 -5
  18. package/src/app/api/hazo_auth/resend_verification/route.ts +4 -4
  19. package/src/app/api/hazo_auth/reset_password/route.ts +5 -5
  20. package/src/app/api/hazo_auth/update_user/route.ts +5 -5
  21. package/src/app/api/hazo_auth/upload_profile_picture/route.ts +8 -8
  22. package/src/app/api/hazo_auth/user_management/permissions/route.ts +4 -4
  23. package/src/app/api/hazo_auth/user_management/roles/route.ts +5 -5
  24. package/src/app/api/hazo_auth/user_management/users/roles/route.ts +5 -5
  25. package/src/app/api/hazo_auth/user_management/users/route.ts +6 -6
  26. package/src/app/api/hazo_auth/validate_reset_token/route.ts +4 -4
  27. package/src/app/api/hazo_auth/verify_email/route.ts +4 -4
  28. package/src/app/api/migrations/apply/route.ts +3 -3
  29. package/src/app/hazo_auth/forgot_password/forgot_password_page_client.tsx +4 -4
  30. package/src/app/hazo_auth/forgot_password/page.tsx +4 -4
  31. package/src/app/hazo_auth/login/login_page_client.tsx +20 -5
  32. package/src/app/hazo_auth/login/page.tsx +17 -5
  33. package/src/app/hazo_auth/my_settings/my_settings_page_client.tsx +3 -3
  34. package/src/app/hazo_auth/my_settings/page.tsx +4 -4
  35. package/src/app/hazo_auth/register/page.tsx +15 -5
  36. package/src/app/hazo_auth/register/register_page_client.tsx +13 -4
  37. package/src/app/hazo_auth/reset_password/page.tsx +4 -4
  38. package/src/app/hazo_auth/reset_password/reset_password_page_client.tsx +4 -4
  39. package/src/app/hazo_auth/user_management/page.tsx +3 -3
  40. package/src/app/hazo_auth/user_management/user_management_page_client.tsx +1 -1
  41. package/src/app/hazo_auth/verify_email/page.tsx +4 -4
  42. package/src/app/hazo_auth/verify_email/verify_email_page_client.tsx +4 -4
  43. package/src/app/hazo_connect/api/sqlite/data/route.ts +1 -1
  44. package/src/app/hazo_connect/api/sqlite/schema/route.ts +1 -1
  45. package/src/app/hazo_connect/api/sqlite/tables/route.ts +1 -1
  46. package/src/app/layout.tsx +1 -1
  47. package/src/app/page.tsx +1 -1
  48. package/src/components/layouts/email_verification/config/email_verification_field_config.ts +2 -2
  49. package/src/components/layouts/email_verification/hooks/use_email_verification.ts +3 -3
  50. package/src/components/layouts/email_verification/index.tsx +11 -11
  51. package/src/components/layouts/forgot_password/config/forgot_password_field_config.ts +2 -2
  52. package/src/components/layouts/forgot_password/hooks/use_forgot_password_form.ts +3 -3
  53. package/src/components/layouts/forgot_password/index.tsx +10 -10
  54. package/src/components/layouts/login/config/login_field_config.ts +2 -2
  55. package/src/components/layouts/login/hooks/use_login_form.ts +18 -13
  56. package/src/components/layouts/login/index.tsx +39 -11
  57. package/src/components/layouts/my_settings/components/editable_field.tsx +3 -3
  58. package/src/components/layouts/my_settings/components/password_change_dialog.tsx +5 -5
  59. package/src/components/layouts/my_settings/components/profile_picture_dialog.tsx +4 -4
  60. package/src/components/layouts/my_settings/components/profile_picture_display.tsx +2 -2
  61. package/src/components/layouts/my_settings/components/profile_picture_gravatar_tab.tsx +3 -3
  62. package/src/components/layouts/my_settings/components/profile_picture_library_tab.tsx +5 -5
  63. package/src/components/layouts/my_settings/components/profile_picture_upload_tab.tsx +4 -4
  64. package/src/components/layouts/my_settings/config/my_settings_field_config.ts +2 -2
  65. package/src/components/layouts/my_settings/hooks/use_my_settings.ts +2 -2
  66. package/src/components/layouts/my_settings/index.tsx +5 -5
  67. package/src/components/layouts/register/config/register_field_config.ts +2 -2
  68. package/src/components/layouts/register/hooks/use_register_form.ts +8 -5
  69. package/src/components/layouts/register/index.tsx +29 -11
  70. package/src/components/layouts/reset_password/config/reset_password_field_config.ts +2 -2
  71. package/src/components/layouts/reset_password/hooks/use_reset_password_form.ts +4 -4
  72. package/src/components/layouts/reset_password/index.tsx +10 -10
  73. package/src/components/layouts/shared/components/auth_page_shell.tsx +36 -0
  74. package/src/components/layouts/shared/components/standalone_layout_wrapper.tsx +53 -0
  75. package/src/components/layouts/user_management/components/roles_matrix.tsx +7 -7
  76. package/src/components/layouts/user_management/index.tsx +10 -10
  77. package/src/components/ui/alert-dialog.tsx +2 -2
  78. package/src/components/ui/avatar.tsx +1 -1
  79. package/src/components/ui/button.tsx +1 -1
  80. package/src/components/ui/checkbox.tsx +1 -1
  81. package/src/components/ui/dialog.tsx +1 -1
  82. package/src/components/ui/dropdown-menu.tsx +1 -1
  83. package/src/components/ui/hazo_ui_tooltip.tsx +1 -1
  84. package/src/components/ui/input.tsx +1 -1
  85. package/src/components/ui/label.tsx +1 -1
  86. package/src/components/ui/separator.tsx +1 -1
  87. package/src/components/ui/sheet.tsx +1 -1
  88. package/src/components/ui/sidebar.tsx +8 -8
  89. package/src/components/ui/skeleton.tsx +1 -1
  90. package/src/components/ui/switch.tsx +1 -1
  91. package/src/components/ui/table.tsx +1 -1
  92. package/src/components/ui/tabs.tsx +1 -1
  93. package/src/components/ui/tooltip.tsx +1 -1
  94. package/src/components/ui/vertical-tabs.tsx +1 -1
  95. package/src/lib/app_logger.ts +1 -1
  96. package/src/lib/config/config_loader.server.ts +20 -5
  97. package/src/lib/login_config.server.ts +25 -0
  98. package/src/lib/register_config.server.ts +17 -1
  99. package/src/lib/services/login_service.ts +19 -3
  100. package/src/lib/services/registration_service.ts +25 -4
  101. package/src/lib/services/user_update_service.ts +16 -3
  102. package/src/lib/ui_shell_config.server.ts +73 -0
  103. package/src/lib/utils/error_sanitizer.ts +75 -0
  104. package/src/stories/email_verification_layout.stories.tsx +2 -2
  105. package/src/stories/forgot_password_layout.stories.tsx +2 -2
  106. package/src/stories/login_layout.stories.tsx +2 -2
  107. package/src/stories/register_layout.stories.tsx +2 -2
  108. package/tsconfig.json +1 -4
@@ -1,16 +1,23 @@
1
1
  // file_description: render the register page shell and mount the register layout component within sidebar
2
2
  // section: imports
3
- import { SidebarLayoutWrapper } from "@/components/layouts/shared/components/sidebar_layout_wrapper";
3
+ import { AuthPageShell } from "../../../components/layouts/shared/components/auth_page_shell";
4
4
  import { RegisterPageClient } from "./register_page_client";
5
- import { get_register_config } from "@/lib/register_config.server";
5
+ import { get_register_config } from "../../../lib/register_config.server";
6
6
 
7
7
  // section: component
8
- export default function register_page() {
8
+ export default function register_page({
9
+ searchParams,
10
+ }: {
11
+ searchParams: { [key: string]: string | string[] | undefined };
12
+ }) {
9
13
  // Read register configuration from hazo_auth_config.ini (server-side)
10
14
  const registerConfig = get_register_config();
11
15
 
16
+ // Get url_on_logon from query params (if any)
17
+ const urlOnLogon = typeof searchParams.url_on_logon === "string" ? searchParams.url_on_logon : undefined;
18
+
12
19
  return (
13
- <SidebarLayoutWrapper>
20
+ <AuthPageShell>
14
21
  <RegisterPageClient
15
22
  showNameField={registerConfig.showNameField}
16
23
  passwordRequirements={registerConfig.passwordRequirements}
@@ -19,8 +26,11 @@ export default function register_page() {
19
26
  showReturnHomeButton={registerConfig.showReturnHomeButton}
20
27
  returnHomeButtonLabel={registerConfig.returnHomeButtonLabel}
21
28
  returnHomePath={registerConfig.returnHomePath}
29
+ signInPath={registerConfig.signInPath}
30
+ signInLabel={registerConfig.signInLabel}
31
+ urlOnLogon={urlOnLogon}
22
32
  />
23
- </SidebarLayoutWrapper>
33
+ </AuthPageShell>
24
34
  );
25
35
  }
26
36
 
@@ -4,10 +4,10 @@
4
4
 
5
5
  // section: imports
6
6
  import { useEffect, useState } from "react";
7
- import register_layout from "@/components/layouts/register";
8
- import { createLayoutDataClient } from "@/components/layouts/shared/data/layout_data_client";
9
- import { create_sqlite_hazo_connect } from "@/lib/hazo_connect_setup";
10
- import type { LayoutDataClient } from "@/components/layouts/shared/data/layout_data_client";
7
+ import register_layout from "../../../components/layouts/register";
8
+ import { createLayoutDataClient } from "../../../components/layouts/shared/data/layout_data_client";
9
+ import { create_sqlite_hazo_connect } from "../../../lib/hazo_connect_setup";
10
+ import type { LayoutDataClient } from "../../../components/layouts/shared/data/layout_data_client";
11
11
 
12
12
  // section: types
13
13
  type RegisterPageClientProps = {
@@ -24,6 +24,9 @@ type RegisterPageClientProps = {
24
24
  showReturnHomeButton?: boolean;
25
25
  returnHomeButtonLabel?: string;
26
26
  returnHomePath?: string;
27
+ signInPath?: string;
28
+ signInLabel?: string;
29
+ urlOnLogon?: string;
27
30
  };
28
31
 
29
32
  // section: component
@@ -35,6 +38,9 @@ export function RegisterPageClient({
35
38
  showReturnHomeButton,
36
39
  returnHomeButtonLabel,
37
40
  returnHomePath,
41
+ signInPath,
42
+ signInLabel,
43
+ urlOnLogon,
38
44
  }: RegisterPageClientProps) {
39
45
  const [dataClient, setDataClient] = useState<LayoutDataClient<unknown> | null>(null);
40
46
 
@@ -66,6 +72,9 @@ export function RegisterPageClient({
66
72
  showReturnHomeButton={showReturnHomeButton}
67
73
  returnHomeButtonLabel={returnHomeButtonLabel}
68
74
  returnHomePath={returnHomePath}
75
+ signInPath={signInPath}
76
+ signInLabel={signInLabel}
77
+ urlOnLogon={urlOnLogon}
69
78
  />
70
79
  );
71
80
  }
@@ -1,8 +1,8 @@
1
1
  // file_description: render the reset password page shell and mount the reset password layout component within sidebar
2
2
  // section: imports
3
- import { SidebarLayoutWrapper } from "@/components/layouts/shared/components/sidebar_layout_wrapper";
3
+ import { AuthPageShell } from "../../../components/layouts/shared/components/auth_page_shell";
4
4
  import { ResetPasswordPageClient } from "./reset_password_page_client";
5
- import { get_reset_password_config } from "@/lib/reset_password_config.server";
5
+ import { get_reset_password_config } from "../../../lib/reset_password_config.server";
6
6
 
7
7
  // section: component
8
8
  export default function reset_password_page() {
@@ -10,7 +10,7 @@ export default function reset_password_page() {
10
10
  const resetPasswordConfig = get_reset_password_config();
11
11
 
12
12
  return (
13
- <SidebarLayoutWrapper>
13
+ <AuthPageShell>
14
14
  <ResetPasswordPageClient
15
15
  errorMessage={resetPasswordConfig.errorMessage}
16
16
  successMessage={resetPasswordConfig.successMessage}
@@ -23,7 +23,7 @@ export default function reset_password_page() {
23
23
  returnHomePath={resetPasswordConfig.returnHomePath}
24
24
  passwordRequirements={resetPasswordConfig.passwordRequirements}
25
25
  />
26
- </SidebarLayoutWrapper>
26
+ </AuthPageShell>
27
27
  );
28
28
  }
29
29
 
@@ -4,10 +4,10 @@
4
4
 
5
5
  // section: imports
6
6
  import { useEffect, useState } from "react";
7
- import reset_password_layout from "@/components/layouts/reset_password";
8
- import { createLayoutDataClient } from "@/components/layouts/shared/data/layout_data_client";
9
- import { create_sqlite_hazo_connect } from "@/lib/hazo_connect_setup";
10
- import type { LayoutDataClient } from "@/components/layouts/shared/data/layout_data_client";
7
+ import reset_password_layout from "../../../components/layouts/reset_password";
8
+ import { createLayoutDataClient } from "../../../components/layouts/shared/data/layout_data_client";
9
+ import { create_sqlite_hazo_connect } from "../../../lib/hazo_connect_setup";
10
+ import type { LayoutDataClient } from "../../../components/layouts/shared/data/layout_data_client";
11
11
 
12
12
  // section: types
13
13
  type ResetPasswordPageClientProps = {
@@ -1,14 +1,14 @@
1
1
  // file_description: render the user management page shell and mount the user management layout component within sidebar
2
2
  // section: imports
3
- import { SidebarLayoutWrapper } from "@/components/layouts/shared/components/sidebar_layout_wrapper";
3
+ import { AuthPageShell } from "../../../components/layouts/shared/components/auth_page_shell";
4
4
  import { UserManagementPageClient } from "./user_management_page_client";
5
5
 
6
6
  // section: component
7
7
  export default function user_management_page() {
8
8
  return (
9
- <SidebarLayoutWrapper>
9
+ <AuthPageShell>
10
10
  <UserManagementPageClient />
11
- </SidebarLayoutWrapper>
11
+ </AuthPageShell>
12
12
  );
13
13
  }
14
14
 
@@ -3,7 +3,7 @@
3
3
  "use client";
4
4
 
5
5
  // section: imports
6
- import { UserManagementLayout } from "@/components/layouts/user_management";
6
+ import { UserManagementLayout } from "../../../components/layouts/user_management";
7
7
 
8
8
  // section: component
9
9
  /**
@@ -1,8 +1,8 @@
1
1
  // file_description: render the email verification page shell and mount the email verification layout component within sidebar
2
2
  // section: imports
3
- import { SidebarLayoutWrapper } from "@/components/layouts/shared/components/sidebar_layout_wrapper";
3
+ import { AuthPageShell } from "../../../components/layouts/shared/components/auth_page_shell";
4
4
  import { VerifyEmailPageClient } from "./verify_email_page_client";
5
- import { get_email_verification_config } from "@/lib/email_verification_config.server";
5
+ import { get_email_verification_config } from "../../../lib/email_verification_config.server";
6
6
 
7
7
  // section: component
8
8
  export default function verify_email_page() {
@@ -10,7 +10,7 @@ export default function verify_email_page() {
10
10
  const emailVerificationConfig = get_email_verification_config();
11
11
 
12
12
  return (
13
- <SidebarLayoutWrapper>
13
+ <AuthPageShell>
14
14
  <VerifyEmailPageClient
15
15
  alreadyLoggedInMessage={emailVerificationConfig.alreadyLoggedInMessage}
16
16
  showLogoutButton={emailVerificationConfig.showLogoutButton}
@@ -18,7 +18,7 @@ export default function verify_email_page() {
18
18
  returnHomeButtonLabel={emailVerificationConfig.returnHomeButtonLabel}
19
19
  returnHomePath={emailVerificationConfig.returnHomePath}
20
20
  />
21
- </SidebarLayoutWrapper>
21
+ </AuthPageShell>
22
22
  );
23
23
  }
24
24
 
@@ -4,10 +4,10 @@
4
4
 
5
5
  // section: imports
6
6
  import { useEffect, useState } from "react";
7
- import email_verification_layout from "@/components/layouts/email_verification";
8
- import { createLayoutDataClient } from "@/components/layouts/shared/data/layout_data_client";
9
- import { create_sqlite_hazo_connect } from "@/lib/hazo_connect_setup";
10
- import type { LayoutDataClient } from "@/components/layouts/shared/data/layout_data_client";
7
+ import email_verification_layout from "../../../components/layouts/email_verification";
8
+ import { createLayoutDataClient } from "../../../components/layouts/shared/data/layout_data_client";
9
+ import { create_sqlite_hazo_connect } from "../../../lib/hazo_connect_setup";
10
+ import type { LayoutDataClient } from "../../../components/layouts/shared/data/layout_data_client";
11
11
 
12
12
  // section: types
13
13
  type VerifyEmailPageClientProps = {
@@ -6,7 +6,7 @@ import {
6
6
  type SqliteFilterOperator,
7
7
  type SqliteWhereFilter
8
8
  } from "hazo_connect/server"
9
- import { get_hazo_connect_instance } from "@/lib/hazo_connect_instance.server"
9
+ import { get_hazo_connect_instance } from "../../../../../lib/hazo_connect_instance.server"
10
10
 
11
11
  export const dynamic = "force-dynamic"
12
12
  const allowedOperators: SqliteFilterOperator[] = [
@@ -1,7 +1,7 @@
1
1
  // file_description: API route to get SQLite table schema for admin UI
2
2
  import { NextRequest, NextResponse } from "next/server"
3
3
  import { getSqliteAdminService } from "hazo_connect/server"
4
- import { get_hazo_connect_instance } from "@/lib/hazo_connect_instance.server"
4
+ import { get_hazo_connect_instance } from "../../../../../lib/hazo_connect_instance.server"
5
5
 
6
6
  export const dynamic = "force-dynamic"
7
7
 
@@ -1,7 +1,7 @@
1
1
  // file_description: API route to list SQLite tables for admin UI
2
2
  import { NextResponse } from "next/server"
3
3
  import { getSqliteAdminService } from "hazo_connect/server"
4
- import { get_hazo_connect_instance } from "@/lib/hazo_connect_instance.server"
4
+ import { get_hazo_connect_instance } from "../../../../../lib/hazo_connect_instance.server"
5
5
 
6
6
  export const dynamic = "force-dynamic"
7
7
 
@@ -1,7 +1,7 @@
1
1
  // file_description: define the root layout wrapper for the hazo_auth project
2
2
  import type { Metadata } from "next";
3
3
  import local_font from "next/font/local";
4
- import { Toaster } from "@/components/ui/sonner";
4
+ import { Toaster } from "../components/ui/sonner";
5
5
  import "./globals.css";
6
6
 
7
7
  // section: typography_setup
package/src/app/page.tsx CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  SidebarProvider,
17
17
  SidebarTrigger,
18
18
  SidebarInset,
19
- } from "@/components/ui/sidebar";
19
+ } from "../components/ui/sidebar";
20
20
  import { LogIn, UserPlus, BookOpen, ExternalLink, Database, KeyRound, MailCheck } from "lucide-react";
21
21
 
22
22
  // section: page_component
@@ -1,6 +1,6 @@
1
1
  // file_description: email verification layout specific configuration helpers
2
2
  // section: imports
3
- import type { LayoutFieldMap, LayoutFieldMapOverrides } from "@/components/layouts/shared/config/layout_customization";
3
+ import type { LayoutFieldMap, LayoutFieldMapOverrides } from "../../shared/config/layout_customization";
4
4
  import {
5
5
  resolveButtonPalette,
6
6
  resolveFieldDefinitions,
@@ -9,7 +9,7 @@ import {
9
9
  type ButtonPaletteOverrides,
10
10
  type LayoutLabelDefaults,
11
11
  type LayoutLabelOverrides,
12
- } from "@/components/layouts/shared/config/layout_customization";
12
+ } from "../../shared/config/layout_customization";
13
13
 
14
14
  // section: field_identifiers
15
15
  export const EMAIL_VERIFICATION_FIELD_IDS = {
@@ -3,9 +3,9 @@
3
3
  import { useCallback, useEffect, useMemo, useState } from "react";
4
4
  import { useRouter, useSearchParams } from "next/navigation";
5
5
  import { toast } from "sonner";
6
- import type { LayoutDataClient } from "@/components/layouts/shared/data/layout_data_client";
7
- import { EMAIL_VERIFICATION_FIELD_IDS, type EmailVerificationFieldId } from "@/components/layouts/email_verification/config/email_verification_field_config";
8
- import { validateEmail } from "@/components/layouts/shared/utils/validation";
6
+ import type { LayoutDataClient } from "../../shared/data/layout_data_client";
7
+ import { EMAIL_VERIFICATION_FIELD_IDS, type EmailVerificationFieldId } from "../config/email_verification_field_config";
8
+ import { validateEmail } from "../../shared/utils/validation";
9
9
 
10
10
  // section: types
11
11
  export type EmailVerificationFormValues = Record<EmailVerificationFieldId, string>;
@@ -3,17 +3,17 @@
3
3
  "use client";
4
4
 
5
5
  // section: imports
6
- import { Input } from "@/components/ui/input";
7
- import { Button } from "@/components/ui/button";
8
- import { FormFieldWrapper } from "@/components/layouts/shared/components/form_field_wrapper";
9
- import { FormHeader } from "@/components/layouts/shared/components/form_header";
10
- import { FormActionButtons } from "@/components/layouts/shared/components/form_action_buttons";
11
- import { TwoColumnAuthLayout } from "@/components/layouts/shared/components/two_column_auth_layout";
6
+ import { Input } from "../../ui/input";
7
+ import { Button } from "../../ui/button";
8
+ import { FormFieldWrapper } from "../shared/components/form_field_wrapper";
9
+ import { FormHeader } from "../shared/components/form_header";
10
+ import { FormActionButtons } from "../shared/components/form_action_buttons";
11
+ import { TwoColumnAuthLayout } from "../shared/components/two_column_auth_layout";
12
12
  import {
13
13
  type ButtonPaletteOverrides,
14
14
  type LayoutFieldMapOverrides,
15
15
  type LayoutLabelOverrides,
16
- } from "@/components/layouts/shared/config/layout_customization";
16
+ } from "../shared/config/layout_customization";
17
17
  import {
18
18
  EMAIL_VERIFICATION_FIELD_IDS,
19
19
  createEmailVerificationFieldDefinitions,
@@ -23,14 +23,14 @@ import {
23
23
  EMAIL_VERIFICATION_ERROR_LABEL_DEFAULTS,
24
24
  type EmailVerificationSuccessLabels,
25
25
  type EmailVerificationErrorLabels,
26
- } from "@/components/layouts/email_verification/config/email_verification_field_config";
26
+ } from "./config/email_verification_field_config";
27
27
  import {
28
28
  use_email_verification,
29
29
  type UseEmailVerificationResult,
30
- } from "@/components/layouts/email_verification/hooks/use_email_verification";
31
- import { type LayoutDataClient } from "@/components/layouts/shared/data/layout_data_client";
30
+ } from "./hooks/use_email_verification";
31
+ import { type LayoutDataClient } from "../shared/data/layout_data_client";
32
32
  import { CheckCircle, XCircle, Loader2 } from "lucide-react";
33
- import { AlreadyLoggedInGuard } from "@/components/layouts/shared/components/already_logged_in_guard";
33
+ import { AlreadyLoggedInGuard } from "../shared/components/already_logged_in_guard";
34
34
 
35
35
  // section: types
36
36
  export type EmailVerificationLayoutProps<TClient = unknown> = {
@@ -1,6 +1,6 @@
1
1
  // file_description: forgot password layout specific configuration helpers
2
2
  // section: imports
3
- import type { LayoutFieldMap, LayoutFieldMapOverrides } from "@/components/layouts/shared/config/layout_customization";
3
+ import type { LayoutFieldMap, LayoutFieldMapOverrides } from "../../shared/config/layout_customization";
4
4
  import {
5
5
  resolveButtonPalette,
6
6
  resolveFieldDefinitions,
@@ -9,7 +9,7 @@ import {
9
9
  type ButtonPaletteOverrides,
10
10
  type LayoutLabelDefaults,
11
11
  type LayoutLabelOverrides,
12
- } from "@/components/layouts/shared/config/layout_customization";
12
+ } from "../../shared/config/layout_customization";
13
13
 
14
14
  // section: field_identifiers
15
15
  export const FORGOT_PASSWORD_FIELD_IDS = {
@@ -2,9 +2,9 @@
2
2
  // section: imports
3
3
  import { useCallback, useMemo, useState } from "react";
4
4
  import { toast } from "sonner";
5
- import type { LayoutDataClient } from "@/components/layouts/shared/data/layout_data_client";
6
- import { FORGOT_PASSWORD_FIELD_IDS, type ForgotPasswordFieldId } from "@/components/layouts/forgot_password/config/forgot_password_field_config";
7
- import { validateEmail } from "@/components/layouts/shared/utils/validation";
5
+ import type { LayoutDataClient } from "../../shared/data/layout_data_client";
6
+ import { FORGOT_PASSWORD_FIELD_IDS, type ForgotPasswordFieldId } from "../config/forgot_password_field_config";
7
+ import { validateEmail } from "../../shared/utils/validation";
8
8
 
9
9
  // section: types
10
10
  export type ForgotPasswordFormValues = Record<ForgotPasswordFieldId, string>;
@@ -3,28 +3,28 @@
3
3
  "use client";
4
4
 
5
5
  // section: imports
6
- import { Input } from "@/components/ui/input";
7
- import { FormFieldWrapper } from "@/components/layouts/shared/components/form_field_wrapper";
8
- import { FormHeader } from "@/components/layouts/shared/components/form_header";
9
- import { FormActionButtons } from "@/components/layouts/shared/components/form_action_buttons";
10
- import { TwoColumnAuthLayout } from "@/components/layouts/shared/components/two_column_auth_layout";
11
- import { AlreadyLoggedInGuard } from "@/components/layouts/shared/components/already_logged_in_guard";
6
+ import { Input } from "../../ui/input";
7
+ import { FormFieldWrapper } from "../shared/components/form_field_wrapper";
8
+ import { FormHeader } from "../shared/components/form_header";
9
+ import { FormActionButtons } from "../shared/components/form_action_buttons";
10
+ import { TwoColumnAuthLayout } from "../shared/components/two_column_auth_layout";
11
+ import { AlreadyLoggedInGuard } from "../shared/components/already_logged_in_guard";
12
12
  import {
13
13
  type ButtonPaletteOverrides,
14
14
  type LayoutFieldMapOverrides,
15
15
  type LayoutLabelOverrides,
16
- } from "@/components/layouts/shared/config/layout_customization";
16
+ } from "../shared/config/layout_customization";
17
17
  import {
18
18
  FORGOT_PASSWORD_FIELD_IDS,
19
19
  createForgotPasswordFieldDefinitions,
20
20
  resolveForgotPasswordButtonPalette,
21
21
  resolveForgotPasswordLabels,
22
- } from "@/components/layouts/forgot_password/config/forgot_password_field_config";
22
+ } from "./config/forgot_password_field_config";
23
23
  import {
24
24
  use_forgot_password_form,
25
25
  type UseForgotPasswordFormResult,
26
- } from "@/components/layouts/forgot_password/hooks/use_forgot_password_form";
27
- import { type LayoutDataClient } from "@/components/layouts/shared/data/layout_data_client";
26
+ } from "./hooks/use_forgot_password_form";
27
+ import { type LayoutDataClient } from "../shared/data/layout_data_client";
28
28
 
29
29
  // section: types
30
30
  export type ForgotPasswordLayoutProps<TClient = unknown> = {
@@ -1,6 +1,6 @@
1
1
  // file_description: login layout specific configuration helpers
2
2
  // section: imports
3
- import type { LayoutFieldMap, LayoutFieldMapOverrides } from "@/components/layouts/shared/config/layout_customization";
3
+ import type { LayoutFieldMap, LayoutFieldMapOverrides } from "../../shared/config/layout_customization";
4
4
  import {
5
5
  resolveButtonPalette,
6
6
  resolveFieldDefinitions,
@@ -9,7 +9,7 @@ import {
9
9
  type ButtonPaletteOverrides,
10
10
  type LayoutLabelDefaults,
11
11
  type LayoutLabelOverrides,
12
- } from "@/components/layouts/shared/config/layout_customization";
12
+ } from "../../shared/config/layout_customization";
13
13
 
14
14
  // section: field_identifiers
15
15
  export const LOGIN_FIELD_IDS = {
@@ -2,11 +2,11 @@
2
2
  // section: imports
3
3
  import { useCallback, useMemo, useState, useEffect } from "react";
4
4
  import { useRouter } from "next/navigation";
5
- import type { LayoutDataClient } from "@/components/layouts/shared/data/layout_data_client";
6
- import { LOGIN_FIELD_IDS, type LoginFieldId } from "@/components/layouts/login/config/login_field_config";
7
- import { validateEmail } from "@/components/layouts/shared/utils/validation";
8
- import { get_client_ip } from "@/components/layouts/shared/utils/ip_address";
9
- import { trigger_auth_status_refresh } from "@/components/layouts/shared/hooks/use_auth_status";
5
+ import type { LayoutDataClient } from "../../shared/data/layout_data_client";
6
+ import { LOGIN_FIELD_IDS, type LoginFieldId } from "../config/login_field_config";
7
+ import { validateEmail } from "../../shared/utils/validation";
8
+ import { get_client_ip } from "../../shared/utils/ip_address";
9
+ import { trigger_auth_status_refresh } from "../../shared/hooks/use_auth_status";
10
10
 
11
11
  // section: types
12
12
  export type LoginFormValues = Record<LoginFieldId, string>;
@@ -25,6 +25,7 @@ export type UseLoginFormParams<TClient = unknown> = {
25
25
  };
26
26
  redirectRoute?: string;
27
27
  successMessage?: string;
28
+ urlOnLogon?: string;
28
29
  };
29
30
 
30
31
  export type UseLoginFormResult = {
@@ -62,6 +63,7 @@ export const use_login_form = <TClient,>({
62
63
  logger,
63
64
  redirectRoute,
64
65
  successMessage = "Successfully logged in",
66
+ urlOnLogon,
65
67
  }: UseLoginFormParams<TClient>): UseLoginFormResult => {
66
68
  const router = useRouter();
67
69
  const [values, setValues] = useState<LoginFormValues>(buildInitialValues);
@@ -87,10 +89,9 @@ export const use_login_form = <TClient,>({
87
89
  }, []);
88
90
 
89
91
  const isSubmitDisabled = useMemo(() => {
90
- const hasEmptyField = Object.values(values).some((fieldValue) => fieldValue.trim() === "");
91
- const hasErrors = Object.keys(errors).length > 0;
92
- return hasEmptyField || hasErrors;
93
- }, [errors, values]);
92
+ const allFieldsEmpty = Object.values(values).every((fieldValue) => fieldValue.trim() === "");
93
+ return allFieldsEmpty;
94
+ }, [values]);
94
95
 
95
96
  const togglePasswordVisibility = useCallback(() => {
96
97
  setPasswordVisibility((previous) => ({
@@ -189,6 +190,7 @@ export const use_login_form = <TClient,>({
189
190
  body: JSON.stringify({
190
191
  email,
191
192
  password,
193
+ url_on_logon: urlOnLogon,
192
194
  }),
193
195
  });
194
196
 
@@ -230,9 +232,12 @@ export const use_login_form = <TClient,>({
230
232
  // Refresh the page to update authentication state (cookies are set server-side)
231
233
  router.refresh();
232
234
 
233
- // If redirect route is provided, redirect to it
234
- if (redirectRoute) {
235
- router.push(redirectRoute);
235
+ // Use redirectUrl from server response if available, otherwise fall back to redirectRoute prop
236
+ // The server logic already prioritizes: query param > stored DB value > config > default "/"
237
+ const finalRedirectUrl = data.redirectUrl || redirectRoute;
238
+
239
+ if (finalRedirectUrl) {
240
+ router.push(finalRedirectUrl);
236
241
  } else {
237
242
  // Otherwise, show success message
238
243
  setIsSuccess(true);
@@ -251,7 +256,7 @@ export const use_login_form = <TClient,>({
251
256
  setIsSuccess(false);
252
257
  }
253
258
  },
254
- [values, clientIp, log_login_attempt, redirectRoute, router],
259
+ [values, clientIp, log_login_attempt, redirectRoute, router, urlOnLogon],
255
260
  );
256
261
 
257
262
  const handleCancel = useCallback(() => {
@@ -3,30 +3,31 @@
3
3
  "use client";
4
4
 
5
5
  // section: imports
6
- import { Input } from "@/components/ui/input";
7
- import { PasswordField } from "@/components/layouts/shared/components/password_field";
8
- import { FormFieldWrapper } from "@/components/layouts/shared/components/form_field_wrapper";
9
- import { FormHeader } from "@/components/layouts/shared/components/form_header";
10
- import { FormActionButtons } from "@/components/layouts/shared/components/form_action_buttons";
11
- import { TwoColumnAuthLayout } from "@/components/layouts/shared/components/two_column_auth_layout";
6
+ import Link from "next/link";
7
+ import { Input } from "../../ui/input";
8
+ import { PasswordField } from "../shared/components/password_field";
9
+ import { FormFieldWrapper } from "../shared/components/form_field_wrapper";
10
+ import { FormHeader } from "../shared/components/form_header";
11
+ import { FormActionButtons } from "../shared/components/form_action_buttons";
12
+ import { TwoColumnAuthLayout } from "../shared/components/two_column_auth_layout";
12
13
  import { CheckCircle } from "lucide-react";
13
- import { AlreadyLoggedInGuard } from "@/components/layouts/shared/components/already_logged_in_guard";
14
+ import { AlreadyLoggedInGuard } from "../shared/components/already_logged_in_guard";
14
15
  import {
15
16
  type ButtonPaletteOverrides,
16
17
  type LayoutFieldMapOverrides,
17
18
  type LayoutLabelOverrides,
18
- } from "@/components/layouts/shared/config/layout_customization";
19
+ } from "../shared/config/layout_customization";
19
20
  import {
20
21
  LOGIN_FIELD_IDS,
21
22
  createLoginFieldDefinitions,
22
23
  resolveLoginButtonPalette,
23
24
  resolveLoginLabels,
24
- } from "@/components/layouts/login/config/login_field_config";
25
+ } from "./config/login_field_config";
25
26
  import {
26
27
  use_login_form,
27
28
  type UseLoginFormResult,
28
- } from "@/components/layouts/login/hooks/use_login_form";
29
- import { type LayoutDataClient } from "@/components/layouts/shared/data/layout_data_client";
29
+ } from "./hooks/use_login_form";
30
+ import { type LayoutDataClient } from "../shared/data/layout_data_client";
30
31
 
31
32
  // section: types
32
33
  export type LoginLayoutProps<TClient = unknown> = {
@@ -50,6 +51,11 @@ export type LoginLayoutProps<TClient = unknown> = {
50
51
  showReturnHomeButton?: boolean;
51
52
  returnHomeButtonLabel?: string;
52
53
  returnHomePath?: string;
54
+ forgot_password_path?: string;
55
+ forgot_password_label?: string;
56
+ create_account_path?: string;
57
+ create_account_label?: string;
58
+ urlOnLogon?: string;
53
59
  };
54
60
 
55
61
  const ORDERED_FIELDS: LoginFieldId[] = [
@@ -76,6 +82,11 @@ export default function login_layout<TClient>({
76
82
  showReturnHomeButton = false,
77
83
  returnHomeButtonLabel = "Return home",
78
84
  returnHomePath = "/",
85
+ forgot_password_path = "/hazo_auth/forgot_password",
86
+ forgot_password_label = "Forgot password?",
87
+ create_account_path = "/hazo_auth/register",
88
+ create_account_label = "Create account",
89
+ urlOnLogon,
79
90
  }: LoginLayoutProps<TClient>) {
80
91
  const fieldDefinitions = createLoginFieldDefinitions(field_overrides);
81
92
  const resolvedLabels = resolveLoginLabels(labels);
@@ -86,6 +97,7 @@ export default function login_layout<TClient>({
86
97
  logger,
87
98
  redirectRoute,
88
99
  successMessage,
100
+ urlOnLogon: urlOnLogon,
89
101
  });
90
102
 
91
103
  const renderFields = (formState: UseLoginFormResult) => {
@@ -214,6 +226,22 @@ export default function login_layout<TClient>({
214
226
  submitAriaLabel="Submit login form"
215
227
  cancelAriaLabel="Cancel login form"
216
228
  />
229
+ <div className="cls_login_layout_support_links flex flex-col gap-1 text-sm text-muted-foreground">
230
+ <Link
231
+ href={forgot_password_path}
232
+ className="cls_login_layout_forgot_password_link text-primary underline-offset-4 hover:underline"
233
+ aria-label="Go to forgot password page"
234
+ >
235
+ {forgot_password_label}
236
+ </Link>
237
+ <Link
238
+ href={create_account_path}
239
+ className="cls_login_layout_create_account_link text-primary underline-offset-4 hover:underline"
240
+ aria-label="Go to create account page"
241
+ >
242
+ {create_account_label}
243
+ </Link>
244
+ </div>
217
245
  </form>
218
246
  </>
219
247
  }
@@ -4,9 +4,9 @@
4
4
 
5
5
  // section: imports
6
6
  import { useState } from "react";
7
- import { Input } from "@/components/ui/input";
8
- import { Label } from "@/components/ui/label";
9
- import { Button } from "@/components/ui/button";
7
+ import { Input } from "../../../ui/input";
8
+ import { Label } from "../../../ui/label";
9
+ import { Button } from "../../../ui/button";
10
10
  import { Pencil, CheckCircle2, XCircle } from "lucide-react";
11
11
 
12
12
  // section: types
@@ -10,11 +10,11 @@ import {
10
10
  DialogHeader,
11
11
  DialogTitle,
12
12
  DialogDescription,
13
- } from "@/components/ui/dialog";
14
- import { Button } from "@/components/ui/button";
15
- import { PasswordField } from "@/components/layouts/shared/components/password_field";
16
- import { FormFieldWrapper } from "@/components/layouts/shared/components/form_field_wrapper";
17
- import type { PasswordRequirementOptions } from "@/components/layouts/shared/config/layout_customization";
13
+ } from "../../../ui/dialog";
14
+ import { Button } from "../../../ui/button";
15
+ import { PasswordField } from "../../shared/components/password_field";
16
+ import { FormFieldWrapper } from "../../shared/components/form_field_wrapper";
17
+ import type { PasswordRequirementOptions } from "../../shared/config/layout_customization";
18
18
 
19
19
  // section: types
20
20
  export type ButtonPalette = {