hazo_auth 1.0.5 → 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 (30) hide show
  1. package/README.md +50 -0
  2. package/hazo_auth_config.example.ini +41 -0
  3. package/instrumentation.ts +2 -2
  4. package/package.json +2 -1
  5. package/scripts/init_users.ts +378 -0
  6. package/src/app/api/hazo_auth/login/route.ts +27 -1
  7. package/src/app/api/hazo_auth/register/route.ts +13 -10
  8. package/src/app/hazo_auth/forgot_password/page.tsx +3 -3
  9. package/src/app/hazo_auth/login/login_page_client.tsx +15 -0
  10. package/src/app/hazo_auth/login/page.tsx +16 -4
  11. package/src/app/hazo_auth/my_settings/page.tsx +3 -3
  12. package/src/app/hazo_auth/register/page.tsx +14 -4
  13. package/src/app/hazo_auth/register/register_page_client.tsx +9 -0
  14. package/src/app/hazo_auth/reset_password/page.tsx +3 -3
  15. package/src/app/hazo_auth/user_management/page.tsx +3 -3
  16. package/src/app/hazo_auth/verify_email/page.tsx +3 -3
  17. package/src/components/layouts/login/hooks/use_login_form.ts +13 -8
  18. package/src/components/layouts/login/index.tsx +28 -0
  19. package/src/components/layouts/register/hooks/use_register_form.ts +4 -1
  20. package/src/components/layouts/register/index.tsx +18 -0
  21. package/src/components/layouts/shared/components/auth_page_shell.tsx +36 -0
  22. package/src/components/layouts/shared/components/standalone_layout_wrapper.tsx +53 -0
  23. package/src/lib/config/config_loader.server.ts +20 -5
  24. package/src/lib/login_config.server.ts +25 -0
  25. package/src/lib/register_config.server.ts +17 -1
  26. package/src/lib/services/login_service.ts +19 -3
  27. package/src/lib/services/registration_service.ts +25 -4
  28. package/src/lib/services/user_update_service.ts +16 -3
  29. package/src/lib/ui_shell_config.server.ts +73 -0
  30. package/src/lib/utils/error_sanitizer.ts +75 -0
@@ -19,6 +19,11 @@ type LoginPageClientProps = {
19
19
  showReturnHomeButton?: boolean;
20
20
  returnHomeButtonLabel?: string;
21
21
  returnHomePath?: string;
22
+ forgotPasswordPath?: string;
23
+ forgotPasswordLabel?: string;
24
+ createAccountPath?: string;
25
+ createAccountLabel?: string;
26
+ urlOnLogon?: string;
22
27
  };
23
28
 
24
29
  // section: component
@@ -30,6 +35,11 @@ export function LoginPageClient({
30
35
  showReturnHomeButton,
31
36
  returnHomeButtonLabel,
32
37
  returnHomePath,
38
+ forgotPasswordPath,
39
+ forgotPasswordLabel,
40
+ createAccountPath,
41
+ createAccountLabel,
42
+ urlOnLogon,
33
43
  }: LoginPageClientProps) {
34
44
  const [dataClient, setDataClient] = useState<LayoutDataClient<unknown> | null>(null);
35
45
  const [logger, setLogger] = useState<ReturnType<typeof create_app_logger> | null>(null);
@@ -65,6 +75,11 @@ export function LoginPageClient({
65
75
  showReturnHomeButton={showReturnHomeButton}
66
76
  returnHomeButtonLabel={returnHomeButtonLabel}
67
77
  returnHomePath={returnHomePath}
78
+ forgot_password_path={forgotPasswordPath}
79
+ forgot_password_label={forgotPasswordLabel}
80
+ create_account_path={createAccountPath}
81
+ create_account_label={createAccountLabel}
82
+ urlOnLogon={urlOnLogon}
68
83
  />
69
84
  );
70
85
  }
@@ -1,16 +1,23 @@
1
1
  // file_description: render the login page shell and mount the login 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 { LoginPageClient } from "./login_page_client";
5
5
  import { get_login_config } from "../../../lib/login_config.server";
6
6
 
7
7
  // section: component
8
- export default function login_page() {
8
+ export default function login_page({
9
+ searchParams,
10
+ }: {
11
+ searchParams: { [key: string]: string | string[] | undefined };
12
+ }) {
9
13
  // Read login configuration from hazo_auth_config.ini (server-side)
10
14
  const loginConfig = get_login_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
  <LoginPageClient
15
22
  redirectRoute={loginConfig.redirectRoute}
16
23
  successMessage={loginConfig.successMessage}
@@ -19,8 +26,13 @@ export default function login_page() {
19
26
  showReturnHomeButton={loginConfig.showReturnHomeButton}
20
27
  returnHomeButtonLabel={loginConfig.returnHomeButtonLabel}
21
28
  returnHomePath={loginConfig.returnHomePath}
29
+ forgotPasswordPath={loginConfig.forgotPasswordPath}
30
+ forgotPasswordLabel={loginConfig.forgotPasswordLabel}
31
+ createAccountPath={loginConfig.createAccountPath}
32
+ createAccountLabel={loginConfig.createAccountLabel}
33
+ urlOnLogon={urlOnLogon}
22
34
  />
23
- </SidebarLayoutWrapper>
35
+ </AuthPageShell>
24
36
  );
25
37
  }
26
38
 
@@ -1,6 +1,6 @@
1
1
  // file_description: render the my settings page shell and mount the my settings 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 { MySettingsPageClient } from "./my_settings_page_client";
5
5
  import { get_my_settings_config } from "../../../lib/my_settings_config.server";
6
6
 
@@ -10,7 +10,7 @@ export default function my_settings_page() {
10
10
  const mySettingsConfig = get_my_settings_config();
11
11
 
12
12
  return (
13
- <SidebarLayoutWrapper>
13
+ <AuthPageShell>
14
14
  <MySettingsPageClient
15
15
  userFields={mySettingsConfig.userFields}
16
16
  passwordRequirements={mySettingsConfig.passwordRequirements}
@@ -34,7 +34,7 @@ export default function my_settings_page() {
34
34
  uiSizes={mySettingsConfig.uiSizes}
35
35
  fileTypes={mySettingsConfig.fileTypes}
36
36
  />
37
- </SidebarLayoutWrapper>
37
+ </AuthPageShell>
38
38
  );
39
39
  }
40
40
 
@@ -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
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
 
@@ -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,6 +1,6 @@
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
5
  import { get_reset_password_config } from "../../../lib/reset_password_config.server";
6
6
 
@@ -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
 
@@ -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
 
@@ -1,6 +1,6 @@
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
5
  import { get_email_verification_config } from "../../../lib/email_verification_config.server";
6
6
 
@@ -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
 
@@ -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,6 +3,7 @@
3
3
  "use client";
4
4
 
5
5
  // section: imports
6
+ import Link from "next/link";
6
7
  import { Input } from "../../ui/input";
7
8
  import { PasswordField } from "../shared/components/password_field";
8
9
  import { FormFieldWrapper } from "../shared/components/form_field_wrapper";
@@ -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
  }
@@ -28,6 +28,7 @@ export type UseRegisterFormParams<TClient = unknown> = {
28
28
  passwordRequirements: PasswordRequirementOptions;
29
29
  passwordRequirementOverrides?: PasswordRequirementOverrides;
30
30
  dataClient: LayoutDataClient<TClient>;
31
+ urlOnLogon?: string;
31
32
  };
32
33
 
33
34
  export type UseRegisterFormResult = {
@@ -58,6 +59,7 @@ export const use_register_form = <TClient,>({
58
59
  showNameField,
59
60
  passwordRequirements,
60
61
  dataClient,
62
+ urlOnLogon,
61
63
  }: UseRegisterFormParams<TClient>): UseRegisterFormResult => {
62
64
  const [values, setValues] = useState<RegisterFormValues>(buildInitialValues);
63
65
  const [errors, setErrors] = useState<RegisterFormErrors>({});
@@ -203,6 +205,7 @@ export const use_register_form = <TClient,>({
203
205
  name: values[REGISTER_FIELD_IDS.NAME] || undefined,
204
206
  email: values[REGISTER_FIELD_IDS.EMAIL],
205
207
  password: values[REGISTER_FIELD_IDS.PASSWORD],
208
+ url_on_logon: urlOnLogon,
206
209
  }),
207
210
  });
208
211
 
@@ -242,7 +245,7 @@ export const use_register_form = <TClient,>({
242
245
  setIsSubmitting(false);
243
246
  }
244
247
  },
245
- [values, passwordRequirements, dataClient],
248
+ [values, passwordRequirements, dataClient, urlOnLogon],
246
249
  );
247
250
 
248
251
  const handleCancel = useCallback(() => {
@@ -3,6 +3,7 @@
3
3
  "use client";
4
4
 
5
5
  // section: imports
6
+ import Link from "next/link";
6
7
  import { Input } from "../../ui/input";
7
8
  import { PasswordField } from "../shared/components/password_field";
8
9
  import { FormFieldWrapper } from "../shared/components/form_field_wrapper";
@@ -45,6 +46,9 @@ export type RegisterLayoutProps<TClient = unknown> = {
45
46
  showReturnHomeButton?: boolean;
46
47
  returnHomeButtonLabel?: string;
47
48
  returnHomePath?: string;
49
+ signInPath?: string;
50
+ signInLabel?: string;
51
+ urlOnLogon?: string;
48
52
  };
49
53
 
50
54
  const ORDERED_FIELDS: RegisterFieldId[] = [
@@ -72,6 +76,9 @@ export default function register_layout<TClient>({
72
76
  showReturnHomeButton = false,
73
77
  returnHomeButtonLabel = "Return home",
74
78
  returnHomePath = "/",
79
+ signInPath = "/hazo_auth/login",
80
+ signInLabel = "Sign in",
81
+ urlOnLogon,
75
82
  }: RegisterLayoutProps<TClient>) {
76
83
  const fieldDefinitions = createRegisterFieldDefinitions(field_overrides);
77
84
  const resolvedLabels = resolveRegisterLabels(labels);
@@ -84,6 +91,7 @@ export default function register_layout<TClient>({
84
91
  showNameField: show_name_field,
85
92
  passwordRequirements: resolvedPasswordRequirements,
86
93
  dataClient: data_client,
94
+ urlOnLogon: urlOnLogon,
87
95
  });
88
96
 
89
97
  const renderFields = (formState: UseRegisterFormResult) => {
@@ -193,6 +201,16 @@ export default function register_layout<TClient>({
193
201
  submitAriaLabel="Submit registration form"
194
202
  cancelAriaLabel="Cancel registration form"
195
203
  />
204
+ <div className="cls_register_layout_sign_in_link flex items-center justify-center gap-1 text-sm text-muted-foreground">
205
+ <span>Already have an account?</span>
206
+ <Link
207
+ href={signInPath}
208
+ className="cls_register_layout_sign_in_link_text text-primary underline-offset-4 hover:underline"
209
+ aria-label="Go to sign in page"
210
+ >
211
+ {signInLabel}
212
+ </Link>
213
+ </div>
196
214
  {form.isSubmitting && (
197
215
  <div className="cls_register_submitting_indicator text-sm text-slate-600 text-center">
198
216
  Registering...
@@ -0,0 +1,36 @@
1
+ // file_description: server component that chooses between sidebar shell and standalone shell
2
+ // section: imports
3
+ import type { ReactNode } from "react";
4
+ import { SidebarLayoutWrapper } from "./sidebar_layout_wrapper";
5
+ import { StandaloneLayoutWrapper } from "./standalone_layout_wrapper";
6
+ import { get_ui_shell_config } from "../../../../lib/ui_shell_config.server";
7
+
8
+ // section: types
9
+ type AuthPageShellProps = {
10
+ children: ReactNode;
11
+ };
12
+
13
+ // section: component
14
+ export function AuthPageShell({ children }: AuthPageShellProps) {
15
+ const uiShellConfig = get_ui_shell_config();
16
+
17
+ if (uiShellConfig.layout_mode === "standalone") {
18
+ return (
19
+ <StandaloneLayoutWrapper
20
+ heading={uiShellConfig.standalone_heading}
21
+ description={uiShellConfig.standalone_description}
22
+ wrapperClassName={uiShellConfig.standalone_wrapper_class}
23
+ contentClassName={uiShellConfig.standalone_content_class}
24
+ showHeading={uiShellConfig.standalone_show_heading}
25
+ showDescription={uiShellConfig.standalone_show_description}
26
+ >
27
+ {children}
28
+ </StandaloneLayoutWrapper>
29
+ );
30
+ }
31
+
32
+ return <SidebarLayoutWrapper>{children}</SidebarLayoutWrapper>;
33
+ }
34
+
35
+
36
+
@@ -0,0 +1,53 @@
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
+
@@ -71,7 +71,12 @@ export function get_config_value(
71
71
  file_path?: string,
72
72
  ): string {
73
73
  const section = read_config_section(section_name, file_path);
74
- return section?.[key]?.trim() || default_value;
74
+ // Optional chaining on section and section[key]
75
+ // If section is undefined, or key is undefined, fall back to default
76
+ if (!section || section[key] === undefined) {
77
+ return default_value;
78
+ }
79
+ return section[key].trim() || default_value;
75
80
  }
76
81
 
77
82
  /**
@@ -89,12 +94,12 @@ export function get_config_boolean(
89
94
  file_path?: string,
90
95
  ): boolean {
91
96
  const section = read_config_section(section_name, file_path);
92
- const value = section?.[key]?.trim().toLowerCase();
93
97
 
94
- if (value === undefined) {
98
+ if (!section || section[key] === undefined) {
95
99
  return default_value;
96
100
  }
97
101
 
102
+ const value = section[key].trim().toLowerCase();
98
103
  return value !== "false" && value !== "0" && value !== "";
99
104
  }
100
105
 
@@ -113,7 +118,12 @@ export function get_config_number(
113
118
  file_path?: string,
114
119
  ): number {
115
120
  const section = read_config_section(section_name, file_path);
116
- const value = section?.[key]?.trim();
121
+
122
+ if (!section || section[key] === undefined) {
123
+ return default_value;
124
+ }
125
+
126
+ const value = section[key].trim();
117
127
 
118
128
  if (!value) {
119
129
  return default_value;
@@ -138,7 +148,12 @@ export function get_config_array(
138
148
  file_path?: string,
139
149
  ): string[] {
140
150
  const section = read_config_section(section_name, file_path);
141
- const value = section?.[key]?.trim();
151
+
152
+ if (!section || section[key] === undefined) {
153
+ return default_value;
154
+ }
155
+
156
+ const value = section[key].trim();
142
157
 
143
158
  if (!value) {
144
159
  return default_value;
@@ -12,6 +12,10 @@ export type LoginConfig = {
12
12
  showReturnHomeButton: boolean;
13
13
  returnHomeButtonLabel: string;
14
14
  returnHomePath: string;
15
+ forgotPasswordPath: string;
16
+ forgotPasswordLabel: string;
17
+ createAccountPath: string;
18
+ createAccountLabel: string;
15
19
  };
16
20
 
17
21
  // section: helpers
@@ -30,6 +34,23 @@ export function get_login_config(): LoginConfig {
30
34
  // Read success message (defaults to "Successfully logged in")
31
35
  const successMessage = get_config_value(section, "success_message", "Successfully logged in");
32
36
 
37
+ const forgotPasswordPath = get_config_value(
38
+ section,
39
+ "forgot_password_path",
40
+ "/hazo_auth/forgot_password"
41
+ );
42
+ const forgotPasswordLabel = get_config_value(
43
+ section,
44
+ "forgot_password_label",
45
+ "Forgot password?"
46
+ );
47
+ const createAccountPath = get_config_value(section, "create_account_path", "/hazo_auth/register");
48
+ const createAccountLabel = get_config_value(
49
+ section,
50
+ "create_account_label",
51
+ "Create account"
52
+ );
53
+
33
54
  // Get shared already logged in config
34
55
  const alreadyLoggedInConfig = get_already_logged_in_config();
35
56
 
@@ -41,6 +62,10 @@ export function get_login_config(): LoginConfig {
41
62
  showReturnHomeButton: alreadyLoggedInConfig.showReturnHomeButton,
42
63
  returnHomeButtonLabel: alreadyLoggedInConfig.returnHomeButtonLabel,
43
64
  returnHomePath: alreadyLoggedInConfig.returnHomePath,
65
+ forgotPasswordPath,
66
+ forgotPasswordLabel,
67
+ createAccountPath,
68
+ createAccountLabel,
44
69
  };
45
70
  }
46
71