hazo_auth 10.19.0 → 10.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/SETUP_CHECKLIST.md +27 -0
- package/cli-src/lib/already_logged_in_config.server.ts +11 -7
- package/cli-src/lib/auth_hooks.ts +52 -0
- package/cli-src/lib/config/config_loader.server.ts +34 -0
- package/cli-src/lib/email_verification_config.server.ts +2 -2
- package/cli-src/lib/forgot_password_config.server.ts +2 -2
- package/cli-src/lib/login_config.server.ts +25 -19
- package/cli-src/lib/my_settings_config.server.ts +22 -15
- package/cli-src/lib/navbar_config.server.ts +12 -8
- package/cli-src/lib/oauth_config.server.ts +14 -22
- package/cli-src/lib/otp_config.server.ts +11 -4
- package/cli-src/lib/profile_pic_menu_config.server.ts +16 -5
- package/cli-src/lib/register_config.server.ts +21 -16
- package/cli-src/lib/reset_password_config.server.ts +11 -17
- package/cli-src/lib/services/oauth_service.ts +16 -0
- package/cli-src/lib/services/otp_service.ts +7 -0
- package/cli-src/lib/services/registration_service.ts +8 -0
- package/cli-src/lib/ui_shell_config.server.ts +11 -13
- package/dist/components/layouts/create_firm/index.d.ts.map +1 -1
- package/dist/components/layouts/create_firm/index.js +4 -3
- package/dist/components/layouts/dev_lock/index.d.ts.map +1 -1
- package/dist/components/layouts/dev_lock/index.js +4 -2
- package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts +5 -4
- package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/config/email_verification_field_config.js +20 -20
- package/dist/components/layouts/email_verification/hooks/use_email_verification.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/hooks/use_email_verification.js +5 -7
- package/dist/components/layouts/email_verification/index.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/index.js +13 -12
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts +3 -2
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.js +16 -16
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.js +5 -7
- package/dist/components/layouts/forgot_password/index.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/index.js +15 -9
- package/dist/components/layouts/legal/legal_acceptance_gate.d.ts.map +1 -1
- package/dist/components/layouts/legal/legal_acceptance_gate.js +5 -3
- package/dist/components/layouts/legal/legal_doc_checkbox_list.d.ts.map +1 -1
- package/dist/components/layouts/legal/legal_doc_checkbox_list.js +3 -1
- package/dist/components/layouts/legal/legal_doc_combined_view.d.ts.map +1 -1
- package/dist/components/layouts/legal/legal_doc_combined_view.js +3 -1
- package/dist/components/layouts/login/config/login_field_config.d.ts +3 -2
- package/dist/components/layouts/login/config/login_field_config.d.ts.map +1 -1
- package/dist/components/layouts/login/config/login_field_config.js +24 -24
- package/dist/components/layouts/login/hooks/use_login_form.d.ts.map +1 -1
- package/dist/components/layouts/login/hooks/use_login_form.js +5 -7
- package/dist/components/layouts/login/index.d.ts +4 -4
- package/dist/components/layouts/login/index.d.ts.map +1 -1
- package/dist/components/layouts/login/index.js +30 -22
- package/dist/components/layouts/my_settings/components/connected_accounts_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/connected_accounts_section.js +5 -5
- package/dist/components/layouts/my_settings/components/danger_zone_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/danger_zone_section.js +12 -6
- package/dist/components/layouts/my_settings/components/editable_field.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/editable_field.js +4 -2
- package/dist/components/layouts/my_settings/components/language_picker_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/language_picker_section.js +7 -3
- package/dist/components/layouts/my_settings/components/password_change_dialog.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/password_change_dialog.js +28 -21
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.js +12 -9
- package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.js +3 -1
- package/dist/components/layouts/my_settings/components/profile_picture_library_tab.js +14 -11
- package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.js +26 -15
- package/dist/components/layouts/my_settings/components/set_password_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/set_password_section.js +9 -6
- package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts +2 -1
- package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/config/my_settings_field_config.js +4 -7
- package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/index.js +35 -27
- package/dist/components/layouts/otp/index.d.ts.map +1 -1
- package/dist/components/layouts/otp/index.js +8 -6
- package/dist/components/layouts/register/config/register_field_config.d.ts +3 -2
- package/dist/components/layouts/register/config/register_field_config.d.ts.map +1 -1
- package/dist/components/layouts/register/config/register_field_config.js +40 -40
- package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -1
- package/dist/components/layouts/register/hooks/use_register_form.js +7 -9
- package/dist/components/layouts/register/index.d.ts +4 -4
- package/dist/components/layouts/register/index.d.ts.map +1 -1
- package/dist/components/layouts/register/index.js +22 -19
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts +4 -3
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/config/reset_password_field_config.js +7 -10
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.js +4 -6
- package/dist/components/layouts/reset_password/index.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/index.js +12 -10
- package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/already_logged_in_guard.js +6 -5
- package/dist/components/layouts/shared/components/auth_navbar.d.ts +1 -1
- package/dist/components/layouts/shared/components/auth_navbar.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/auth_navbar.js +7 -2
- package/dist/components/layouts/shared/components/facebook_sign_in_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/facebook_sign_in_button.js +5 -5
- package/dist/components/layouts/shared/components/floating_home_link.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/floating_home_link.js +6 -3
- package/dist/components/layouts/shared/components/form_action_buttons.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/form_action_buttons.js +9 -7
- package/dist/components/layouts/shared/components/google_sign_in_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/google_sign_in_button.js +5 -5
- package/dist/components/layouts/shared/components/logout_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/logout_button.js +2 -4
- package/dist/components/layouts/shared/components/oauth_divider.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/oauth_divider.js +8 -6
- package/dist/components/layouts/shared/components/password_field.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/password_field.js +2 -3
- package/dist/components/layouts/shared/components/profile_pic_menu.d.ts +4 -0
- package/dist/components/layouts/shared/components/profile_pic_menu.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/profile_pic_menu.js +26 -18
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.d.ts +1 -0
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.js +1 -1
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.js +3 -1
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.js +6 -2
- package/dist/components/layouts/shared/components/unauthorized_guard.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/unauthorized_guard.js +6 -5
- package/dist/components/layouts/shared/config/layout_customization.d.ts +2 -1
- package/dist/components/layouts/shared/config/layout_customization.d.ts.map +1 -1
- package/dist/components/layouts/shared/config/layout_customization.js +18 -7
- package/dist/components/layouts/shared/utils/validation.d.ts +5 -2
- package/dist/components/layouts/shared/utils/validation.d.ts.map +1 -1
- package/dist/components/layouts/shared/utils/validation.js +4 -8
- package/dist/components/layouts/user_management/components/roles_matrix.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/roles_matrix.js +2 -4
- package/dist/components/layouts/user_management/components/scope_hierarchy_tab.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/scope_hierarchy_tab.js +6 -8
- package/dist/components/layouts/user_management/components/user_scopes_tab.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/user_scopes_tab.js +2 -4
- package/dist/components/layouts/user_management/index.d.ts.map +1 -1
- package/dist/components/layouts/user_management/index.js +2 -4
- package/dist/components/otp/OTPRequestForm.d.ts.map +1 -1
- package/dist/components/otp/OTPRequestForm.js +7 -5
- package/dist/components/otp/OTPVerifyForm.d.ts.map +1 -1
- package/dist/components/otp/OTPVerifyForm.js +7 -5
- package/dist/components/permission_denied_dialog.client.d.ts.map +1 -1
- package/dist/components/permission_denied_dialog.client.js +6 -6
- package/dist/components/ui/sheet.d.ts +1 -1
- package/dist/components/ui/sidebar.js +5 -5
- package/dist/contexts/hazo_auth_config.d.ts +13 -0
- package/dist/contexts/hazo_auth_config.d.ts.map +1 -1
- package/dist/contexts/hazo_auth_config.js +4 -1
- package/dist/contexts/hazo_auth_provider.d.ts +22 -2
- package/dist/contexts/hazo_auth_provider.d.ts.map +1 -1
- package/dist/contexts/hazo_auth_provider.js +18 -2
- package/dist/lib/already_logged_in_config.server.d.ts +4 -2
- package/dist/lib/already_logged_in_config.server.d.ts.map +1 -1
- package/dist/lib/already_logged_in_config.server.js +7 -5
- package/dist/lib/auth_hooks.d.ts +20 -0
- package/dist/lib/auth_hooks.d.ts.map +1 -0
- package/dist/lib/auth_hooks.js +32 -0
- package/dist/lib/config/config_loader.server.d.ts +23 -0
- package/dist/lib/config/config_loader.server.d.ts.map +1 -1
- package/dist/lib/config/config_loader.server.js +29 -0
- package/dist/lib/email_verification_config.server.d.ts +2 -2
- package/dist/lib/email_verification_config.server.d.ts.map +1 -1
- package/dist/lib/forgot_password_config.server.d.ts +2 -2
- package/dist/lib/forgot_password_config.server.d.ts.map +1 -1
- package/dist/lib/login_config.server.d.ts +8 -5
- package/dist/lib/login_config.server.d.ts.map +1 -1
- package/dist/lib/login_config.server.js +13 -6
- package/dist/lib/my_settings_config.server.d.ts.map +1 -1
- package/dist/lib/my_settings_config.server.js +22 -15
- package/dist/lib/navbar_config.server.d.ts +3 -2
- package/dist/lib/navbar_config.server.d.ts.map +1 -1
- package/dist/lib/navbar_config.server.js +4 -2
- package/dist/lib/oauth_config.server.d.ts +6 -6
- package/dist/lib/oauth_config.server.d.ts.map +1 -1
- package/dist/lib/oauth_config.server.js +8 -4
- package/dist/lib/otp_config.server.d.ts +2 -2
- package/dist/lib/otp_config.server.d.ts.map +1 -1
- package/dist/lib/otp_config.server.js +4 -2
- package/dist/lib/profile_pic_menu_config.server.d.ts +6 -2
- package/dist/lib/profile_pic_menu_config.server.d.ts.map +1 -1
- package/dist/lib/profile_pic_menu_config.server.js +5 -3
- package/dist/lib/register_config.server.d.ts +7 -6
- package/dist/lib/register_config.server.d.ts.map +1 -1
- package/dist/lib/register_config.server.js +8 -4
- package/dist/lib/reset_password_config.server.d.ts +6 -4
- package/dist/lib/reset_password_config.server.d.ts.map +1 -1
- package/dist/lib/reset_password_config.server.js +5 -5
- package/dist/lib/services/oauth_service.d.ts.map +1 -1
- package/dist/lib/services/oauth_service.js +13 -0
- package/dist/lib/services/otp_service.d.ts.map +1 -1
- package/dist/lib/services/otp_service.js +6 -0
- package/dist/lib/services/registration_service.d.ts.map +1 -1
- package/dist/lib/services/registration_service.js +7 -0
- package/dist/lib/ui_shell_config.server.d.ts +6 -2
- package/dist/lib/ui_shell_config.server.d.ts.map +1 -1
- package/dist/lib/ui_shell_config.server.js +5 -3
- package/dist/locales/en.json +135 -1
- package/dist/server-lib.d.ts +2 -0
- package/dist/server-lib.d.ts.map +1 -1
- package/dist/server-lib.js +2 -0
- package/dist/server_pages/forgot_password.d.ts +3 -2
- package/dist/server_pages/forgot_password.d.ts.map +1 -1
- package/dist/server_pages/forgot_password.js +8 -7
- package/dist/server_pages/forgot_password_client_wrapper.d.ts +2 -1
- package/dist/server_pages/forgot_password_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/forgot_password_client_wrapper.js +3 -1
- package/dist/server_pages/login.d.ts.map +1 -1
- package/dist/server_pages/login.js +9 -7
- package/dist/server_pages/login_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/login_client_wrapper.js +3 -1
- package/dist/server_pages/otp.d.ts +6 -3
- package/dist/server_pages/otp.d.ts.map +1 -1
- package/dist/server_pages/otp.js +11 -8
- package/dist/server_pages/register.d.ts.map +1 -1
- package/dist/server_pages/register.js +7 -6
- package/dist/server_pages/register_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/register_client_wrapper.js +3 -1
- package/dist/server_pages/reset_password.d.ts.map +1 -1
- package/dist/server_pages/reset_password.js +7 -6
- package/dist/server_pages/reset_password_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/reset_password_client_wrapper.js +3 -1
- package/dist/server_pages/verify_email.d.ts.map +1 -1
- package/dist/server_pages/verify_email.js +6 -5
- package/dist/server_pages/verify_email_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/verify_email_client_wrapper.js +4 -2
- package/dist/strings/default_strings.d.ts +15 -0
- package/dist/strings/default_strings.d.ts.map +1 -1
- package/dist/strings/default_strings.js +53 -0
- package/dist/strings/index.d.ts +1 -1
- package/dist/strings/index.d.ts.map +1 -1
- package/dist/strings/index.js +1 -1
- package/dist/strings/strings_context.d.ts +20 -3
- package/dist/strings/strings_context.d.ts.map +1 -1
- package/dist/strings/strings_context.js +39 -5
- package/dist/strings/strings_provider.d.ts +1 -5
- package/dist/strings/strings_provider.d.ts.map +1 -1
- package/dist/strings/strings_provider.js +5 -1
- package/package.json +10 -6
|
@@ -4,10 +4,7 @@ import { useCallback, useMemo, useState } from "react";
|
|
|
4
4
|
import { toast } from "sonner";
|
|
5
5
|
import { REGISTER_FIELD_IDS } from "../config/register_field_config.js";
|
|
6
6
|
import { validateEmail, validatePassword } from "../../shared/utils/validation.js";
|
|
7
|
-
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider.js";
|
|
8
|
-
import en from "../../../../locales/en.json" with { type: "json" };
|
|
9
|
-
import { createPackageT } from "hazo_core/i18n";
|
|
10
|
-
const t = createPackageT("hazo_auth", en);
|
|
7
|
+
import { useHazoAuthConfig, useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
11
8
|
// section: constants
|
|
12
9
|
const PASSWORD_FIELDS = [
|
|
13
10
|
REGISTER_FIELD_IDS.PASSWORD,
|
|
@@ -23,6 +20,7 @@ const buildInitialValues = () => ({
|
|
|
23
20
|
// section: hook
|
|
24
21
|
export const use_register_form = ({ showNameField, passwordRequirements, dataClient, urlOnLogon, legalDocs, }) => {
|
|
25
22
|
const { apiBasePath } = useHazoAuthConfig();
|
|
23
|
+
const t = useAuthT();
|
|
26
24
|
const initialValues = useMemo(() => buildInitialValues(), []);
|
|
27
25
|
const [values, setValues] = useState(initialValues);
|
|
28
26
|
const [errors, setErrors] = useState({});
|
|
@@ -89,7 +87,7 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
89
87
|
const updatedErrors = Object.assign({}, previousErrors);
|
|
90
88
|
// Only validate email on change if it has been touched (blurred)
|
|
91
89
|
if (fieldId === REGISTER_FIELD_IDS.EMAIL && emailTouched) {
|
|
92
|
-
const emailError = validateEmail(value);
|
|
90
|
+
const emailError = validateEmail(value, t);
|
|
93
91
|
if (emailError) {
|
|
94
92
|
updatedErrors[REGISTER_FIELD_IDS.EMAIL] = emailError;
|
|
95
93
|
}
|
|
@@ -98,7 +96,7 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
98
96
|
}
|
|
99
97
|
}
|
|
100
98
|
if (PASSWORD_FIELDS.includes(fieldId)) {
|
|
101
|
-
const passwordError = validatePassword(nextValues[REGISTER_FIELD_IDS.PASSWORD], passwordRequirements);
|
|
99
|
+
const passwordError = validatePassword(nextValues[REGISTER_FIELD_IDS.PASSWORD], passwordRequirements, t);
|
|
102
100
|
if (passwordError) {
|
|
103
101
|
updatedErrors[REGISTER_FIELD_IDS.PASSWORD] = passwordError;
|
|
104
102
|
}
|
|
@@ -125,7 +123,7 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
125
123
|
setErrors((previousErrors) => {
|
|
126
124
|
const updatedErrors = Object.assign({}, previousErrors);
|
|
127
125
|
const emailValue = values[REGISTER_FIELD_IDS.EMAIL];
|
|
128
|
-
const emailError = validateEmail(emailValue);
|
|
126
|
+
const emailError = validateEmail(emailValue, t);
|
|
129
127
|
if (emailError) {
|
|
130
128
|
updatedErrors[REGISTER_FIELD_IDS.EMAIL] = emailError;
|
|
131
129
|
}
|
|
@@ -138,8 +136,8 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
138
136
|
const handleSubmit = useCallback(async (event) => {
|
|
139
137
|
event.preventDefault();
|
|
140
138
|
// Final validation
|
|
141
|
-
const emailError = validateEmail(values[REGISTER_FIELD_IDS.EMAIL]);
|
|
142
|
-
const passwordError = validatePassword(values[REGISTER_FIELD_IDS.PASSWORD], passwordRequirements);
|
|
139
|
+
const emailError = validateEmail(values[REGISTER_FIELD_IDS.EMAIL], t);
|
|
140
|
+
const passwordError = validatePassword(values[REGISTER_FIELD_IDS.PASSWORD], passwordRequirements, t);
|
|
143
141
|
if (emailError || passwordError) {
|
|
144
142
|
setErrors(Object.assign(Object.assign({}, (emailError ? { [REGISTER_FIELD_IDS.EMAIL]: emailError } : {})), (passwordError ? { [REGISTER_FIELD_IDS.PASSWORD]: passwordError } : {})));
|
|
145
143
|
return;
|
|
@@ -6,10 +6,10 @@ export type OAuthLayoutConfig = {
|
|
|
6
6
|
enable_google: boolean;
|
|
7
7
|
/** Enable traditional email/password login */
|
|
8
8
|
enable_email_password: boolean;
|
|
9
|
-
/** Text displayed on the Google sign-in button */
|
|
10
|
-
google_button_text
|
|
11
|
-
/** Text displayed on the divider between OAuth and email/password form */
|
|
12
|
-
oauth_divider_text
|
|
9
|
+
/** Text displayed on the Google sign-in button. Undefined falls back to `t("register.oauth.google_button_default")`. */
|
|
10
|
+
google_button_text?: string;
|
|
11
|
+
/** Text displayed on the divider between OAuth and email/password form. Undefined falls back to `t("shared.oauth_divider_default")`. */
|
|
12
|
+
oauth_divider_text?: string;
|
|
13
13
|
/** Enable Facebook OAuth login */
|
|
14
14
|
enable_facebook_oauth?: boolean;
|
|
15
15
|
/** Text displayed on the Facebook sign-in button */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/register/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAClC,MAAM,uCAAuC,CAAC;AAY/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/register/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAClC,MAAM,uCAAuC,CAAC;AAY/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAOlD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,gCAAgC;IAChC,aAAa,EAAE,OAAO,CAAC;IACvB,8CAA8C;IAC9C,qBAAqB,EAAE,OAAO,CAAC;IAC/B,wHAAwH;IACxH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,wIAAwI;IACxI,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kCAAkC;IAClC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,oDAAoD;IACpD,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,OAAO,GAAG,OAAO,IAAI;IACnD,6HAA6H;IAC7H,SAAS,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC;IACrC,0GAA0G;IAC1G,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,qBAAqB,CAAC,EAAE,4BAA4B,CAAC;IACrD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACvC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,qGAAqG;IACrG,MAAM,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC;CACrC,CAAC;AAYF,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,OAAO,EAAE,EAC/C,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,eAAe,EACf,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,eAAsB,EACtB,WAAW,EACX,sBAAsB,EACtB,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqB,EACrB,cAAoB,EACpB,UAA+B,EAC/B,WAAW,EACX,UAAU,EACV,KAAK,EACL,MAAqB,GACtB,EAAE,mBAAmB,CAAC,OAAO,CAAC,+BA8R9B"}
|
|
@@ -21,10 +21,7 @@ import { REGISTER_FIELD_IDS, createRegisterFieldDefinitions, resolveRegisterButt
|
|
|
21
21
|
import { use_register_form, } from "./hooks/use_register_form.js";
|
|
22
22
|
import { LegalDocCheckboxList } from "../legal/legal_doc_checkbox_list.js";
|
|
23
23
|
import { LegalDocCombinedView } from "../legal/legal_doc_combined_view.js";
|
|
24
|
-
import { useHazoAuthConfig } from "../../../contexts/hazo_auth_provider.js";
|
|
25
|
-
import en from "../../../locales/en.json" with { type: "json" };
|
|
26
|
-
import { createPackageT } from "hazo_core/i18n";
|
|
27
|
-
const t = createPackageT("hazo_auth", en);
|
|
24
|
+
import { useHazoAuthConfig, useAuthT } from "../../../contexts/hazo_auth_provider.js";
|
|
28
25
|
const ORDERED_FIELDS = [
|
|
29
26
|
REGISTER_FIELD_IDS.NAME,
|
|
30
27
|
REGISTER_FIELD_IDS.EMAIL,
|
|
@@ -32,16 +29,22 @@ const ORDERED_FIELDS = [
|
|
|
32
29
|
REGISTER_FIELD_IDS.CONFIRM_PASSWORD,
|
|
33
30
|
];
|
|
34
31
|
// section: component
|
|
35
|
-
export default function register_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, password_requirements, show_name_field = true, data_client, alreadyLoggedInMessage
|
|
36
|
-
var _a;
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
export default function register_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, password_requirements, show_name_field = true, data_client, alreadyLoggedInMessage, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel, returnHomePath = "/", signInPath = "/hazo_auth/login", signInLabel, urlOnLogon, oauth, layout = "two_column", }) {
|
|
33
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
34
|
+
const t = useAuthT();
|
|
35
|
+
const resolvedAlreadyLoggedInMessage = alreadyLoggedInMessage !== null && alreadyLoggedInMessage !== void 0 ? alreadyLoggedInMessage : t("shared.guard.already_logged_in_prop_default");
|
|
36
|
+
const resolvedReturnHomeButtonLabel = returnHomeButtonLabel !== null && returnHomeButtonLabel !== void 0 ? returnHomeButtonLabel : t("shared.guard.return_home_default");
|
|
37
|
+
const resolvedSignInLabel = signInLabel !== null && signInLabel !== void 0 ? signInLabel : t("shared.sign_in_default");
|
|
38
|
+
// Resolve OAuth config per-field (not `oauth || {defaults}` as a whole
|
|
39
|
+
// object) — see LoginLayout for the full rationale: a partial `oauth` prop
|
|
40
|
+
// must still get `t()`-resolved locale-aware text for any field it left unset.
|
|
41
|
+
const oauthConfig = {
|
|
42
|
+
enable_google: (_a = oauth === null || oauth === void 0 ? void 0 : oauth.enable_google) !== null && _a !== void 0 ? _a : true,
|
|
43
|
+
enable_email_password: (_b = oauth === null || oauth === void 0 ? void 0 : oauth.enable_email_password) !== null && _b !== void 0 ? _b : true,
|
|
44
|
+
google_button_text: (_c = oauth === null || oauth === void 0 ? void 0 : oauth.google_button_text) !== null && _c !== void 0 ? _c : t("register.oauth.google_button_default"),
|
|
45
|
+
oauth_divider_text: (_d = oauth === null || oauth === void 0 ? void 0 : oauth.oauth_divider_text) !== null && _d !== void 0 ? _d : t("shared.oauth_divider_default"),
|
|
46
|
+
enable_facebook_oauth: (_e = oauth === null || oauth === void 0 ? void 0 : oauth.enable_facebook_oauth) !== null && _e !== void 0 ? _e : false,
|
|
47
|
+
facebook_button_text: (_f = oauth === null || oauth === void 0 ? void 0 : oauth.facebook_button_text) !== null && _f !== void 0 ? _f : t("shared.oauth.facebook_button_default"),
|
|
45
48
|
};
|
|
46
49
|
// Read OAuth error from URL query params (e.g., ?error=AccessDenied)
|
|
47
50
|
const searchParams = useSearchParams();
|
|
@@ -56,7 +59,7 @@ export default function register_layout({ image_src, image_alt, image_background
|
|
|
56
59
|
const oauthCallbackUrl = safeRedirect
|
|
57
60
|
? `/api/hazo_auth/oauth/google/callback?next=${encodeURIComponent(safeRedirect)}`
|
|
58
61
|
: "/api/hazo_auth/oauth/google/callback";
|
|
59
|
-
const effectiveUrlOnLogon = (
|
|
62
|
+
const effectiveUrlOnLogon = (_g = urlOnLogon !== null && urlOnLogon !== void 0 ? urlOnLogon : safeRedirect) !== null && _g !== void 0 ? _g : undefined;
|
|
60
63
|
const getOAuthErrorMessage = (error) => {
|
|
61
64
|
switch (error) {
|
|
62
65
|
case "AccessDenied":
|
|
@@ -84,8 +87,8 @@ export default function register_layout({ image_src, image_alt, image_background
|
|
|
84
87
|
})
|
|
85
88
|
.catch(() => { });
|
|
86
89
|
}, [apiBasePath]);
|
|
87
|
-
const fieldDefinitions = createRegisterFieldDefinitions(field_overrides);
|
|
88
|
-
const resolvedLabels = resolveRegisterLabels(labels);
|
|
90
|
+
const fieldDefinitions = createRegisterFieldDefinitions(t, field_overrides);
|
|
91
|
+
const resolvedLabels = resolveRegisterLabels(t, labels);
|
|
89
92
|
const resolvedButtonPalette = resolveRegisterButtonPalette(button_colors);
|
|
90
93
|
const resolvedPasswordRequirements = resolveRegisterPasswordRequirements(password_requirements);
|
|
91
94
|
const form = use_register_form({
|
|
@@ -121,13 +124,13 @@ export default function register_layout({ image_src, image_alt, image_background
|
|
|
121
124
|
// Form content — used in both layout modes. See `login_layout` for the
|
|
122
125
|
// rationale: keeps the form independent of TwoColumnAuthLayout / AuthPageShell
|
|
123
126
|
// so consumers can compose it into their own brand chrome.
|
|
124
|
-
const mainContent = (_jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), oauthError && (_jsxs("div", { className: "cls_register_layout_oauth_error flex items-center gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700", children: [_jsx(AlertCircle, { className: "h-4 w-4 shrink-0", "aria-hidden": "true" }), _jsx("span", { children: getOAuthErrorMessage(oauthError) })] })), oauthConfig.enable_google && (_jsx("div", { className: "cls_register_layout_oauth_section", children: _jsx(GoogleSignInButton, { label: oauthConfig.google_button_text, callbackUrl: oauthCallbackUrl }) })), oauthConfig.enable_facebook_oauth && (_jsx("div", { className: "cls_register_layout_facebook_section", children: _jsx(FacebookSignInButton, { label: oauthConfig.facebook_button_text || t("shared.oauth.facebook_button_default"), callbackUrl: "/api/hazo_auth/oauth/facebook/callback" }) })), (oauthConfig.enable_google || oauthConfig.enable_facebook_oauth) && oauthConfig.enable_email_password && (_jsx(OAuthDivider, { text: oauthConfig.oauth_divider_text })), oauthConfig.enable_email_password && (_jsxs("form", { className: "cls_register_layout_form_fields flex flex-col gap-5", onSubmit: form.handleSubmit, "aria-label": t("register.aria.form"), children: [renderFields(form), legal_docs.length > 0 && (_jsx("div", { className: "space-y-2", children: legal_display_mode === 'combined' ? (_jsx(LegalDocCombinedView, { docs: legal_docs, accepted: legal_docs.every(doc => form.legal_accepted[doc.key]), onAcceptedChange: (value) => legal_docs.forEach(doc => form.handleLegalAcceptedChange(doc.key, value)) })) : (_jsx(LegalDocCheckboxList, { docs: legal_docs, accepted: form.legal_accepted, onAcceptedChange: form.handleLegalAcceptedChange })) })), _jsx(FormActionButtons, { submitLabel: resolvedLabels.submitButton, cancelLabel: resolvedLabels.cancelButton, buttonPalette: resolvedButtonPalette, isSubmitDisabled: form.isSubmitDisabled, onCancel: form.handleCancel, submitAriaLabel: t("register.aria.submit"), cancelAriaLabel: t("register.aria.cancel") }), _jsxs("div", { className: "cls_register_layout_sign_in_link flex items-center justify-center gap-1 text-sm text-muted-foreground", children: [_jsx("span", { children: t("register.sign_in_prompt") }), _jsx(Link, { href: signInPath, className: "cls_register_layout_sign_in_link_text text-primary underline-offset-4 hover:underline", "aria-label": t("register.aria.sign_in_link"), children:
|
|
127
|
+
const mainContent = (_jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), oauthError && (_jsxs("div", { className: "cls_register_layout_oauth_error flex items-center gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700", children: [_jsx(AlertCircle, { className: "h-4 w-4 shrink-0", "aria-hidden": "true" }), _jsx("span", { children: getOAuthErrorMessage(oauthError) })] })), oauthConfig.enable_google && (_jsx("div", { className: "cls_register_layout_oauth_section", children: _jsx(GoogleSignInButton, { label: oauthConfig.google_button_text, callbackUrl: oauthCallbackUrl }) })), oauthConfig.enable_facebook_oauth && (_jsx("div", { className: "cls_register_layout_facebook_section", children: _jsx(FacebookSignInButton, { label: oauthConfig.facebook_button_text || t("shared.oauth.facebook_button_default"), callbackUrl: "/api/hazo_auth/oauth/facebook/callback" }) })), (oauthConfig.enable_google || oauthConfig.enable_facebook_oauth) && oauthConfig.enable_email_password && (_jsx(OAuthDivider, { text: oauthConfig.oauth_divider_text })), oauthConfig.enable_email_password && (_jsxs("form", { className: "cls_register_layout_form_fields flex flex-col gap-5", onSubmit: form.handleSubmit, "aria-label": t("register.aria.form"), children: [renderFields(form), legal_docs.length > 0 && (_jsx("div", { className: "space-y-2", children: legal_display_mode === 'combined' ? (_jsx(LegalDocCombinedView, { docs: legal_docs, accepted: legal_docs.every(doc => form.legal_accepted[doc.key]), onAcceptedChange: (value) => legal_docs.forEach(doc => form.handleLegalAcceptedChange(doc.key, value)) })) : (_jsx(LegalDocCheckboxList, { docs: legal_docs, accepted: form.legal_accepted, onAcceptedChange: form.handleLegalAcceptedChange })) })), _jsx(FormActionButtons, { submitLabel: resolvedLabels.submitButton, cancelLabel: resolvedLabels.cancelButton, buttonPalette: resolvedButtonPalette, isSubmitDisabled: form.isSubmitDisabled, onCancel: form.handleCancel, submitAriaLabel: t("register.aria.submit"), cancelAriaLabel: t("register.aria.cancel") }), _jsxs("div", { className: "cls_register_layout_sign_in_link flex items-center justify-center gap-1 text-sm text-muted-foreground", children: [_jsx("span", { children: t("register.sign_in_prompt") }), _jsx(Link, { href: signInPath, className: "cls_register_layout_sign_in_link_text text-primary underline-offset-4 hover:underline", "aria-label": t("register.aria.sign_in_link"), children: resolvedSignInLabel })] }), form.isSubmitting && (_jsx("div", { className: "cls_register_submitting_indicator text-sm text-slate-600 text-center", children: t("register.submitting_indicator") }))] })), !oauthConfig.enable_email_password && (oauthConfig.enable_google || oauthConfig.enable_facebook_oauth) && (_jsxs("div", { className: "cls_register_layout_sign_in_link mt-4 flex items-center justify-center gap-1 text-sm text-muted-foreground", children: [_jsx("span", { children: t("register.sign_in_prompt") }), _jsx(Link, { href: signInPath, className: "cls_register_layout_sign_in_link_text text-primary underline-offset-4 hover:underline", "aria-label": t("register.aria.sign_in_link"), children: resolvedSignInLabel })] }))] }));
|
|
125
128
|
// form_only mode: emit just the form content. See login_layout for the
|
|
126
129
|
// rationale; AlreadyLoggedInGuard is intentionally skipped here.
|
|
127
130
|
if (layout === "form_only") {
|
|
128
131
|
return mainContent;
|
|
129
132
|
}
|
|
130
|
-
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message:
|
|
133
|
+
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: resolvedAlreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: mainContent }) }));
|
|
131
134
|
}
|
|
132
135
|
// Same-origin path validator. See login/index.tsx for the rationale.
|
|
133
136
|
function isSafeRedirectPath(value) {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { LayoutFieldMap, LayoutFieldMapOverrides } from "../../shared/config/layout_customization";
|
|
2
2
|
import { type ButtonPaletteDefaults, type ButtonPaletteOverrides, type LayoutLabelDefaults, type LayoutLabelOverrides, type PasswordRequirementOptions, type PasswordRequirementOverrides } from "../../shared/config/layout_customization.js";
|
|
3
|
+
import type { AuthTFunction } from "../../../../contexts/hazo_auth_config";
|
|
3
4
|
export declare const RESET_PASSWORD_FIELD_IDS: {
|
|
4
5
|
readonly PASSWORD: "password";
|
|
5
6
|
readonly CONFIRM_PASSWORD: "confirm_password";
|
|
6
7
|
};
|
|
7
8
|
export type ResetPasswordFieldId = (typeof RESET_PASSWORD_FIELD_IDS)[keyof typeof RESET_PASSWORD_FIELD_IDS];
|
|
8
|
-
export declare const createResetPasswordFieldDefinitions: (overrides?: LayoutFieldMapOverrides) => LayoutFieldMap;
|
|
9
|
-
export declare const resolveResetPasswordLabels: (overrides?: LayoutLabelOverrides) => LayoutLabelDefaults;
|
|
9
|
+
export declare const createResetPasswordFieldDefinitions: (t: AuthTFunction, overrides?: LayoutFieldMapOverrides) => LayoutFieldMap;
|
|
10
|
+
export declare const resolveResetPasswordLabels: (t: AuthTFunction, overrides?: LayoutLabelOverrides) => LayoutLabelDefaults;
|
|
10
11
|
export declare const resolveResetPasswordButtonPalette: (overrides?: ButtonPaletteOverrides) => ButtonPaletteDefaults;
|
|
11
12
|
export declare const resolveResetPasswordPasswordRequirements: (overrides?: PasswordRequirementOverrides) => PasswordRequirementOptions;
|
|
12
|
-
export declare const
|
|
13
|
+
export declare const getResetPasswordAlreadyLoggedInMessageDefault: (t: AuthTFunction) => string;
|
|
13
14
|
//# sourceMappingURL=reset_password_field_config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset_password_field_config.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/reset_password/config/reset_password_field_config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACxG,OAAO,EAIL,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EAElC,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"reset_password_field_config.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/reset_password/config/reset_password_field_config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACxG,OAAO,EAIL,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EAElC,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAG3E,eAAO,MAAM,wBAAwB;;;CAG3B,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAC;AAsB5G,eAAO,MAAM,mCAAmC,GAC9C,GAAG,aAAa,EAChB,YAAY,uBAAuB,mBACyC,CAAC;AAU/E,eAAO,MAAM,0BAA0B,GAAI,GAAG,aAAa,EAAE,YAAY,oBAAoB,wBAC/B,CAAC;AAU/D,eAAO,MAAM,iCAAiC,GAAI,YAAY,sBAAsB,0BACX,CAAC;AAW1E,eAAO,MAAM,wCAAwC,GACnD,YAAY,4BAA4B,+BAC+C,CAAC;AAG1F,eAAO,MAAM,6CAA6C,GAAI,GAAG,aAAa,WACjC,CAAC"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { resolveButtonPalette, resolveFieldDefinitions, resolveLabels, resolvePasswordRequirements, } from "../../shared/config/layout_customization.js";
|
|
2
|
-
import en from "../../../../locales/en.json" with { type: "json" };
|
|
3
|
-
import { createPackageT } from "hazo_core/i18n";
|
|
4
|
-
const t = createPackageT("hazo_auth", en);
|
|
5
2
|
// section: field_identifiers
|
|
6
3
|
export const RESET_PASSWORD_FIELD_IDS = {
|
|
7
4
|
PASSWORD: "password",
|
|
8
5
|
CONFIRM_PASSWORD: "confirm_password",
|
|
9
6
|
};
|
|
10
7
|
// section: field_definitions
|
|
11
|
-
const
|
|
8
|
+
const buildResetPasswordFieldDefinitions = (t) => ({
|
|
12
9
|
[RESET_PASSWORD_FIELD_IDS.PASSWORD]: {
|
|
13
10
|
id: RESET_PASSWORD_FIELD_IDS.PASSWORD,
|
|
14
11
|
label: t("reset_password.field.password.label"),
|
|
@@ -25,16 +22,16 @@ const RESET_PASSWORD_FIELD_DEFINITIONS = {
|
|
|
25
22
|
placeholder: t("reset_password.field.confirm_password.placeholder"),
|
|
26
23
|
ariaLabel: t("reset_password.field.confirm_password.aria_label"),
|
|
27
24
|
},
|
|
28
|
-
};
|
|
29
|
-
export const createResetPasswordFieldDefinitions = (overrides) => resolveFieldDefinitions(
|
|
25
|
+
});
|
|
26
|
+
export const createResetPasswordFieldDefinitions = (t, overrides) => resolveFieldDefinitions(buildResetPasswordFieldDefinitions(t), overrides);
|
|
30
27
|
// section: label_defaults
|
|
31
|
-
const
|
|
28
|
+
const buildResetPasswordLabelDefaults = (t) => ({
|
|
32
29
|
heading: t("reset_password.heading"),
|
|
33
30
|
subHeading: t("reset_password.sub_heading"),
|
|
34
31
|
submitButton: t("reset_password.submit_button"),
|
|
35
32
|
cancelButton: t("shared.cancel_button"),
|
|
36
|
-
};
|
|
37
|
-
export const resolveResetPasswordLabels = (overrides) => resolveLabels(
|
|
33
|
+
});
|
|
34
|
+
export const resolveResetPasswordLabels = (t, overrides) => resolveLabels(buildResetPasswordLabelDefaults(t), overrides);
|
|
38
35
|
// section: button_palette_defaults
|
|
39
36
|
const RESET_PASSWORD_BUTTON_PALETTE_DEFAULTS = {
|
|
40
37
|
submitBackground: "#0f172a",
|
|
@@ -53,4 +50,4 @@ const RESET_PASSWORD_PASSWORD_REQUIREMENT_DEFAULTS = {
|
|
|
53
50
|
};
|
|
54
51
|
export const resolveResetPasswordPasswordRequirements = (overrides) => resolvePasswordRequirements(RESET_PASSWORD_PASSWORD_REQUIREMENT_DEFAULTS, overrides);
|
|
55
52
|
// section: already_logged_in_label
|
|
56
|
-
export const
|
|
53
|
+
export const getResetPasswordAlreadyLoggedInMessageDefault = (t) => t("shared.guard.already_logged_in_message");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_reset_password_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/reset_password/hooks/use_reset_password_form.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAC3F,OAAO,EAA4B,KAAK,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"use_reset_password_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/reset_password/hooks/use_reset_password_form.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAC3F,OAAO,EAA4B,KAAK,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAW5G,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;AAC3E,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;AAC/F,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C,OAAO,CAAC,oBAAoB,EAAE,UAAU,GAAG,kBAAkB,CAAC,EAC9D,OAAO,CACR,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,OAAO,GAAG,OAAO,IAAI;IAC1D,oBAAoB,EAAE,0BAA0B,CAAC;IACjD,UAAU,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,MAAM,EAAE,uBAAuB,CAAC;IAChC,MAAM,EAAE,uBAAuB,CAAC;IAChC,kBAAkB,EAAE,uBAAuB,CAAC;IAC5C,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,iBAAiB,EAAE,CAAC,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1E,wBAAwB,EAAE,CAAC,OAAO,EAAE,UAAU,GAAG,kBAAkB,KAAK,IAAI,CAAC;IAC7E,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;IAChE,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B,CAAC;AASF,eAAO,MAAM,uBAAuB,GAAI,OAAO,EAAG,kDAI/C,0BAA0B,CAAC,OAAO,CAAC,KAAG,0BA2NxC,CAAC"}
|
|
@@ -5,10 +5,7 @@ import { useSearchParams, useRouter } from "next/navigation";
|
|
|
5
5
|
import { toast } from "sonner";
|
|
6
6
|
import { RESET_PASSWORD_FIELD_IDS } from "../config/reset_password_field_config.js";
|
|
7
7
|
import { validatePassword } from "../../shared/utils/validation.js";
|
|
8
|
-
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider.js";
|
|
9
|
-
import en from "../../../../locales/en.json" with { type: "json" };
|
|
10
|
-
import { createPackageT } from "hazo_core/i18n";
|
|
11
|
-
const t = createPackageT("hazo_auth", en);
|
|
8
|
+
import { useHazoAuthConfig, useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
12
9
|
// section: constants
|
|
13
10
|
const PASSWORD_FIELDS = [
|
|
14
11
|
RESET_PASSWORD_FIELD_IDS.PASSWORD,
|
|
@@ -22,6 +19,7 @@ const buildInitialValues = () => ({
|
|
|
22
19
|
// section: hook
|
|
23
20
|
export const use_reset_password_form = ({ passwordRequirements, dataClient, loginPath = "/hazo_auth/login", }) => {
|
|
24
21
|
const { apiBasePath } = useHazoAuthConfig();
|
|
22
|
+
const t = useAuthT();
|
|
25
23
|
const router = useRouter();
|
|
26
24
|
const searchParams = useSearchParams();
|
|
27
25
|
const tokenParam = searchParams.get("token");
|
|
@@ -95,7 +93,7 @@ export const use_reset_password_form = ({ passwordRequirements, dataClient, logi
|
|
|
95
93
|
}
|
|
96
94
|
// Validate password fields in real-time
|
|
97
95
|
if (fieldId === RESET_PASSWORD_FIELD_IDS.PASSWORD) {
|
|
98
|
-
const passwordError = validatePassword(value, passwordRequirements);
|
|
96
|
+
const passwordError = validatePassword(value, passwordRequirements, t);
|
|
99
97
|
if (passwordError) {
|
|
100
98
|
setErrors((prev) => (Object.assign(Object.assign({}, prev), { [RESET_PASSWORD_FIELD_IDS.PASSWORD]: passwordError })));
|
|
101
99
|
}
|
|
@@ -143,7 +141,7 @@ export const use_reset_password_form = ({ passwordRequirements, dataClient, logi
|
|
|
143
141
|
return;
|
|
144
142
|
}
|
|
145
143
|
// Validate all fields
|
|
146
|
-
const passwordError = validatePassword(values[RESET_PASSWORD_FIELD_IDS.PASSWORD], passwordRequirements);
|
|
144
|
+
const passwordError = validatePassword(values[RESET_PASSWORD_FIELD_IDS.PASSWORD], passwordRequirements, t);
|
|
147
145
|
const confirmPasswordError = values[RESET_PASSWORD_FIELD_IDS.PASSWORD] !== values[RESET_PASSWORD_FIELD_IDS.CONFIRM_PASSWORD]
|
|
148
146
|
? t("validation.passwords_do_not_match")
|
|
149
147
|
: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/reset_password/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAOlD,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAClC,MAAM,uCAAuC,CAAC;AAY/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/reset_password/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAOlD,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAClC,MAAM,uCAAuC,CAAC;AAY/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAK1E,MAAM,MAAM,wBAAwB,CAAC,OAAO,GAAG,OAAO,IAAI;IACxD,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,qBAAqB,CAAC,EAAE,4BAA4B,CAAC;IACrD,WAAW,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACvC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAUF,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,OAAO,EAAE,EACrD,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,eAAe,EACf,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,WAAW,EACX,sBAAsB,EACtB,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqB,EACrB,cAAoB,EACpB,YAAY,EACZ,cAAc,EACd,SAA8B,EAC9B,kBAAiD,GAClD,EAAE,wBAAwB,CAAC,OAAO,CAAC,+BA0NnC"}
|
|
@@ -13,17 +13,19 @@ import { AlreadyLoggedInGuard } from "../shared/components/already_logged_in_gua
|
|
|
13
13
|
import { RESET_PASSWORD_FIELD_IDS, createResetPasswordFieldDefinitions, resolveResetPasswordButtonPalette, resolveResetPasswordLabels, resolveResetPasswordPasswordRequirements, } from "./config/reset_password_field_config.js";
|
|
14
14
|
import { use_reset_password_form, } from "./hooks/use_reset_password_form.js";
|
|
15
15
|
import Link from "next/link";
|
|
16
|
-
import
|
|
17
|
-
import { createPackageT } from "hazo_core/i18n";
|
|
18
|
-
const t = createPackageT("hazo_auth", en);
|
|
16
|
+
import { useAuthT } from "../../../contexts/hazo_auth_provider.js";
|
|
19
17
|
const ORDERED_FIELDS = [
|
|
20
18
|
RESET_PASSWORD_FIELD_IDS.PASSWORD,
|
|
21
19
|
RESET_PASSWORD_FIELD_IDS.CONFIRM_PASSWORD,
|
|
22
20
|
];
|
|
23
21
|
// section: component
|
|
24
|
-
export default function reset_password_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, password_requirements, data_client, alreadyLoggedInMessage, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel
|
|
25
|
-
const
|
|
26
|
-
const
|
|
22
|
+
export default function reset_password_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, password_requirements, data_client, alreadyLoggedInMessage, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel, returnHomePath = "/", errorMessage, successMessage, loginPath = "/hazo_auth/login", forgotPasswordPath = "/hazo_auth/forgot_password", }) {
|
|
23
|
+
const t = useAuthT();
|
|
24
|
+
const resolvedReturnHomeButtonLabel = returnHomeButtonLabel !== null && returnHomeButtonLabel !== void 0 ? returnHomeButtonLabel : t("shared.guard.return_home_default");
|
|
25
|
+
const resolvedErrorMessage = errorMessage !== null && errorMessage !== void 0 ? errorMessage : t("reset_password.link_invalid_message");
|
|
26
|
+
const resolvedSuccessMessage = successMessage !== null && successMessage !== void 0 ? successMessage : t("reset_password.success_message_default");
|
|
27
|
+
const fieldDefinitions = createResetPasswordFieldDefinitions(t, field_overrides);
|
|
28
|
+
const resolvedLabels = resolveResetPasswordLabels(t, labels);
|
|
27
29
|
const resolvedButtonPalette = resolveResetPasswordButtonPalette(button_colors);
|
|
28
30
|
const resolvedPasswordRequirements = resolveResetPasswordPasswordRequirements(password_requirements);
|
|
29
31
|
const form = use_reset_password_form({
|
|
@@ -42,15 +44,15 @@ export default function reset_password_layout({ image_src, image_alt, image_back
|
|
|
42
44
|
};
|
|
43
45
|
// Show success message if password reset was successful
|
|
44
46
|
if (form.isSuccess) {
|
|
45
|
-
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: alreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel:
|
|
47
|
+
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: alreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), _jsxs("div", { className: "cls_reset_password_layout_success flex flex-col items-center justify-center gap-4 p-8 text-center", children: [_jsx(CheckCircle, { className: "cls_reset_password_layout_success_icon h-16 w-16 text-green-600", "aria-hidden": "true" }), _jsx("p", { className: "cls_reset_password_layout_success_message text-lg font-medium text-slate-900", children: resolvedSuccessMessage })] })] }) }) }));
|
|
46
48
|
}
|
|
47
49
|
// Show loading state while validating token
|
|
48
50
|
if (form.isValidatingToken) {
|
|
49
|
-
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: alreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel:
|
|
51
|
+
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: alreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs("div", { className: "cls_reset_password_layout_validating flex flex-col items-center justify-center gap-4 py-8", children: [_jsx(Loader2, { className: "h-12 w-12 animate-spin text-slate-600", "aria-hidden": "true" }), _jsxs("div", { className: "cls_reset_password_layout_validating_text text-center", children: [_jsx("h1", { className: "cls_reset_password_layout_validating_heading text-2xl font-semibold text-slate-900", children: resolvedLabels.heading }), _jsx("p", { className: "cls_reset_password_layout_validating_subheading mt-2 text-sm text-slate-600", children: t("reset_password.validating_message") })] })] }) }) }));
|
|
50
52
|
}
|
|
51
53
|
// Show error message if token is invalid or missing
|
|
52
54
|
if (form.tokenError || !form.token) {
|
|
53
|
-
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: alreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel:
|
|
55
|
+
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: alreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs("div", { className: "cls_reset_password_layout_error flex flex-col items-center justify-center gap-4 p-8 text-center", children: [_jsx(XCircle, { className: "cls_reset_password_layout_error_icon h-16 w-16 text-red-600", "aria-hidden": "true" }), _jsxs("div", { className: "cls_reset_password_layout_error_text", children: [_jsx("h1", { className: "cls_reset_password_layout_error_heading text-2xl font-semibold text-slate-900", children: t("reset_password.invalid_link_heading") }), _jsx("p", { className: "cls_reset_password_layout_error_message mt-2 text-sm text-slate-600", children: form.tokenError || resolvedErrorMessage })] }), _jsx(Link, { href: forgotPasswordPath, className: "cls_reset_password_layout_forgot_password_link mt-4 text-sm text-blue-600 hover:text-blue-800 underline", children: t("reset_password.invalid_link_page_link") })] }) }) }));
|
|
54
56
|
}
|
|
55
|
-
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: alreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel:
|
|
57
|
+
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: alreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), _jsxs("form", { className: "cls_reset_password_layout_form_fields flex flex-col gap-5", onSubmit: form.handleSubmit, "aria-label": t("reset_password.aria.form"), children: [renderFields(form), _jsx(FormActionButtons, { submitLabel: resolvedLabels.submitButton, cancelLabel: resolvedLabels.cancelButton, buttonPalette: resolvedButtonPalette, isSubmitDisabled: form.isSubmitDisabled, onCancel: form.handleCancel, submitAriaLabel: t("reset_password.aria.submit"), cancelAriaLabel: t("reset_password.aria.cancel") }), form.isSubmitting && (_jsx("div", { className: "cls_reset_password_layout_submitting_indicator text-sm text-slate-600 text-center", children: t("reset_password.submitting_indicator") }))] })] }) }) }));
|
|
56
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"already_logged_in_guard.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/shared/components/already_logged_in_guard.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"already_logged_in_guard.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/shared/components/already_logged_in_guard.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlD,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAGF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,OAAO,EACP,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqB,EACrB,cAAoB,EACpB,oBAA4B,EAC5B,QAAQ,GACT,EAAE,yBAAyB,+BAoD3B"}
|
|
@@ -9,9 +9,7 @@ import { Button } from "../../../ui/button.js";
|
|
|
9
9
|
import { TwoColumnAuthLayout } from "./two_column_auth_layout.js";
|
|
10
10
|
import { useRouter } from "next/navigation";
|
|
11
11
|
import { Home } from "lucide-react";
|
|
12
|
-
import
|
|
13
|
-
import { createPackageT } from "hazo_core/i18n";
|
|
14
|
-
const t = createPackageT("hazo_auth", en);
|
|
12
|
+
import { useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
15
13
|
// section: component
|
|
16
14
|
/**
|
|
17
15
|
* Guard component that shows "already logged in" message if user is authenticated
|
|
@@ -19,7 +17,10 @@ const t = createPackageT("hazo_auth", en);
|
|
|
19
17
|
* @param props - Component props including layout config and message customization
|
|
20
18
|
* @returns Either the "already logged in" UI or the children
|
|
21
19
|
*/
|
|
22
|
-
export function AlreadyLoggedInGuard({ image_src, image_alt, image_background_color = "#f1f5f9", message
|
|
20
|
+
export function AlreadyLoggedInGuard({ image_src, image_alt, image_background_color = "#f1f5f9", message, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel, returnHomePath = "/", requireEmailVerified = false, children, }) {
|
|
21
|
+
const t = useAuthT();
|
|
22
|
+
const resolvedMessage = message !== null && message !== void 0 ? message : t("shared.guard.already_logged_in_message");
|
|
23
|
+
const resolvedReturnHomeButtonLabel = returnHomeButtonLabel !== null && returnHomeButtonLabel !== void 0 ? returnHomeButtonLabel : t("shared.guard.return_home_default");
|
|
23
24
|
const router = useRouter();
|
|
24
25
|
const authStatus = use_auth_status();
|
|
25
26
|
// Check if user should see "already logged in" message
|
|
@@ -29,7 +30,7 @@ export function AlreadyLoggedInGuard({ image_src, image_alt, image_background_co
|
|
|
29
30
|
!authStatus.loading &&
|
|
30
31
|
(!requireEmailVerified || authStatus.email_verified === true);
|
|
31
32
|
if (shouldShowAlreadyLoggedIn) {
|
|
32
|
-
return (_jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs("div", { className: "cls_already_logged_in_guard flex flex-col items-center justify-center gap-4 p-8 text-center", children: [_jsx("p", { className: "cls_already_logged_in_guard_message text-lg font-medium text-slate-900", children:
|
|
33
|
+
return (_jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs("div", { className: "cls_already_logged_in_guard flex flex-col items-center justify-center gap-4 p-8 text-center", children: [_jsx("p", { className: "cls_already_logged_in_guard_message text-lg font-medium text-slate-900", children: resolvedMessage }), _jsxs("div", { className: "cls_already_logged_in_guard_actions flex flex-col gap-3 items-center mt-4", children: [showLogoutButton && (_jsx(LogoutButton, { className: "cls_already_logged_in_guard_logout_button", variant: "default" })), showReturnHomeButton && (_jsxs(Button, { onClick: () => router.push(returnHomePath), variant: "outline", className: "cls_already_logged_in_guard_return_home_button", "aria-label": resolvedReturnHomeButtonLabel, children: [_jsx(Home, { className: "h-4 w-4 mr-2", "aria-hidden": "true" }), resolvedReturnHomeButtonLabel] }))] })] }) }));
|
|
33
34
|
}
|
|
34
35
|
return _jsx(_Fragment, { children: children });
|
|
35
36
|
}
|
|
@@ -9,7 +9,7 @@ export type AuthNavbarProps = {
|
|
|
9
9
|
company_name?: string;
|
|
10
10
|
/** Home link path */
|
|
11
11
|
home_path?: string;
|
|
12
|
-
/** Home link label */
|
|
12
|
+
/** Home link label. Undefined falls back to `t("navbar.home_label_default")`. */
|
|
13
13
|
home_label?: string;
|
|
14
14
|
/** Show home link */
|
|
15
15
|
show_home_link?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth_navbar.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/shared/components/auth_navbar.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth_navbar.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/shared/components/auth_navbar.tsx"],"names":[],"mappings":"AAYA,MAAM,MAAM,eAAe,GAAG;IAC5B,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iFAAiF;IACjF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,8BAA8B;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wBAAwB;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAGF,wBAAgB,UAAU,CAAC,EACzB,SAAc,EACd,UAAe,EACf,WAAgB,EAChB,YAAiB,EACjB,SAAe,EACf,UAAU,EACV,cAAqB,EACrB,gBAAgB,EAChB,UAAU,EACV,MAAW,EACX,SAAS,GACV,EAAE,eAAe,+BA0DjB"}
|
|
@@ -7,11 +7,16 @@ import Link from "next/link";
|
|
|
7
7
|
import Image from "next/image";
|
|
8
8
|
import { Home } from "lucide-react";
|
|
9
9
|
import { cn } from "../../../../lib/utils.js";
|
|
10
|
+
import { useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
10
11
|
// section: component
|
|
11
|
-
export function AuthNavbar({ logo_path = "", logo_width = 28, logo_height = 28, company_name = "", home_path = "/", home_label
|
|
12
|
+
export function AuthNavbar({ logo_path = "", logo_width = 28, logo_height = 28, company_name = "", home_path = "/", home_label, show_home_link = true, background_color, text_color, height = 40, className, }) {
|
|
13
|
+
const t = useAuthT();
|
|
14
|
+
const resolvedHomeLabel = home_label !== null && home_label !== void 0 ? home_label : t("navbar.home_label_default");
|
|
12
15
|
// Only show logo if logo_path is configured (non-empty)
|
|
13
16
|
const showLogo = logo_path !== "";
|
|
14
17
|
const hasBrand = showLogo || company_name !== "";
|
|
15
18
|
const navStyle = Object.assign(Object.assign({ height: `${height}px` }, (background_color && { backgroundColor: background_color })), (text_color && { color: text_color }));
|
|
16
|
-
return (_jsx("nav", { className: cn("cls_auth_navbar flex w-full items-center justify-between border-b border-border/40 bg-background/95 px-4 backdrop-blur supports-[backdrop-filter]:bg-background/60", className), style: navStyle, "aria-label": "
|
|
19
|
+
return (_jsx("nav", { className: cn("cls_auth_navbar flex w-full items-center justify-between border-b border-border/40 bg-background/95 px-4 backdrop-blur supports-[backdrop-filter]:bg-background/60", className), style: navStyle, "aria-label": t("navbar.aria.navigation_default"), children: _jsxs("div", { className: "cls_auth_navbar_brand flex items-center gap-3", children: [hasBrand && (_jsxs(Link, { href: home_path, className: "cls_auth_navbar_logo_link flex items-center gap-3", children: [showLogo && (_jsx(Image, { src: logo_path, alt: company_name
|
|
20
|
+
? t("navbar.company_logo_alt_default", { company_name })
|
|
21
|
+
: t("navbar.logo_alt_default"), width: logo_width, height: logo_height, className: "cls_auth_navbar_logo object-contain" })), company_name && (_jsx("span", { className: "cls_auth_navbar_company_name text-lg font-semibold text-foreground", children: company_name }))] })), !hasBrand && show_home_link && (_jsxs(Link, { href: home_path, className: "cls_auth_navbar_home_link flex items-center gap-2 text-sm font-medium text-muted-foreground transition-colors hover:text-foreground", "aria-label": t("navbar.aria.navigate_to_default", { label: resolvedHomeLabel }), children: [_jsx(Home, { className: "h-4 w-4", "aria-hidden": "true" }), _jsx("span", { children: resolvedHomeLabel })] }))] }) }));
|
|
17
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facebook_sign_in_button.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/shared/components/facebook_sign_in_button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"facebook_sign_in_button.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/shared/components/facebook_sign_in_button.tsx"],"names":[],"mappings":"AAsBA,MAAM,MAAM,yBAAyB,GAAG;IACtC,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAGF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,OAAO,EACP,QAAgB,EAChB,SAAS,EACT,WAAsD,GACvD,EAAE,yBAAyB,+BA+C3B;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -8,9 +8,7 @@ import { cn } from "../../../../lib/utils.js";
|
|
|
8
8
|
import { useState } from "react";
|
|
9
9
|
import { Loader2 } from "lucide-react";
|
|
10
10
|
import { signIn } from "next-auth/react";
|
|
11
|
-
import
|
|
12
|
-
import { createPackageT } from "hazo_core/i18n";
|
|
13
|
-
const t = createPackageT("hazo_auth", en);
|
|
11
|
+
import { useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
14
12
|
// Facebook "f" icon as inline SVG (no external dep)
|
|
15
13
|
function FacebookIcon({ className }) {
|
|
16
14
|
return (_jsx("svg", { className: cn("h-5 w-5", className), viewBox: "0 0 24 24", fill: "#1877F2", "aria-hidden": "true", children: _jsx("path", { d: "M24 12.073C24 5.404 18.627 0 12 0S0 5.404 0 12.073C0 18.1 4.388 23.094 10.125 24v-8.437H7.078v-3.49h3.047V9.413c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.49h-2.796V24C19.612 23.094 24 18.1 24 12.073z" }) }));
|
|
@@ -22,7 +20,9 @@ function FacebookIcon({ className }) {
|
|
|
22
20
|
* Initiates the Facebook OAuth flow when clicked
|
|
23
21
|
* Uses next-auth/react signIn function for proper OAuth flow
|
|
24
22
|
*/
|
|
25
|
-
export function FacebookSignInButton({ label
|
|
23
|
+
export function FacebookSignInButton({ label, onClick, disabled = false, className, callbackUrl = "/api/hazo_auth/oauth/facebook/callback", }) {
|
|
24
|
+
const t = useAuthT();
|
|
25
|
+
const resolvedLabel = label !== null && label !== void 0 ? label : t("shared.oauth.facebook_button_default");
|
|
26
26
|
const [isLoading, setIsLoading] = useState(false);
|
|
27
27
|
const handleClick = async () => {
|
|
28
28
|
if (disabled || isLoading)
|
|
@@ -45,6 +45,6 @@ export function FacebookSignInButton({ label = t("shared.oauth.facebook_button_d
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
return (_jsxs(Button, { type: "button", variant: "outline", onClick: handleClick, disabled: disabled || isLoading, className: cn("cls_facebook_sign_in_button w-full flex items-center justify-center gap-3 h-11 border-slate-300 hover:bg-slate-50 hover:border-slate-400 transition-colors", className), "aria-label":
|
|
48
|
+
return (_jsxs(Button, { type: "button", variant: "outline", onClick: handleClick, disabled: disabled || isLoading, className: cn("cls_facebook_sign_in_button w-full flex items-center justify-center gap-3 h-11 border-slate-300 hover:bg-slate-50 hover:border-slate-400 transition-colors", className), "aria-label": resolvedLabel, children: [isLoading ? (_jsx(Loader2, { className: "h-5 w-5 animate-spin text-slate-600", "aria-hidden": "true" })) : (_jsx(FacebookIcon, { className: "h-5 w-5" })), _jsx("span", { className: "text-slate-700 font-medium", children: isLoading ? t("shared.oauth.signing_in") : resolvedLabel })] }));
|
|
49
49
|
}
|
|
50
50
|
export default FacebookSignInButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floating_home_link.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/shared/components/floating_home_link.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"floating_home_link.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/shared/components/floating_home_link.tsx"],"names":[],"mappings":"AAWA,MAAM,MAAM,qBAAqB,GAAG;IAClC,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAGF;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,IAAU,EACV,KAAK,EACL,SAAS,GACV,EAAE,qBAAqB,+BAsBvB;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -6,6 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
import Link from "next/link";
|
|
7
7
|
import { ArrowLeft } from "lucide-react";
|
|
8
8
|
import { cn } from "../../../../lib/utils.js";
|
|
9
|
+
import { useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
9
10
|
// section: component
|
|
10
11
|
/**
|
|
11
12
|
* Floating "← Back to home" link. Renders fixed top-left of the viewport so
|
|
@@ -16,14 +17,16 @@ import { cn } from "../../../../lib/utils.js";
|
|
|
16
17
|
* Reads label/path from props so consumers can localise — the navbar config
|
|
17
18
|
* helper `get_navbar_config()` is the typical source on the server side.
|
|
18
19
|
*/
|
|
19
|
-
export function FloatingHomeLink({ path = "/", label
|
|
20
|
-
|
|
20
|
+
export function FloatingHomeLink({ path = "/", label, className, }) {
|
|
21
|
+
const t = useAuthT();
|
|
22
|
+
const resolvedLabel = label !== null && label !== void 0 ? label : t("shared.floating_home_link.label");
|
|
23
|
+
return (_jsxs(Link, { href: path, "aria-label": resolvedLabel, className: cn(
|
|
21
24
|
// Positioning: fixed top-left, above auth content, with a healthy
|
|
22
25
|
// safe-area margin so it never collides with brand-panel chrome.
|
|
23
26
|
"cls_floating_home_link fixed left-4 top-4 z-50 inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-sm font-medium",
|
|
24
27
|
// Visuals: subtle pill that adapts to whatever brand backdrop the
|
|
25
28
|
// consumer has rendered. Uses neutral text so it works on both light
|
|
26
29
|
// brand panels and dark ones.
|
|
27
|
-
"bg-background/70 text-foreground/80 shadow-sm backdrop-blur-sm transition-colors hover:bg-background hover:text-foreground", className), children: [_jsx(ArrowLeft, { className: "h-4 w-4", "aria-hidden": "true" }), _jsx("span", { children:
|
|
30
|
+
"bg-background/70 text-foreground/80 shadow-sm backdrop-blur-sm transition-colors hover:bg-background hover:text-foreground", className), children: [_jsx(ArrowLeft, { className: "h-4 w-4", "aria-hidden": "true" }), _jsx("span", { children: resolvedLabel })] }));
|
|
28
31
|
}
|
|
29
32
|
export default FloatingHomeLink;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form_action_buttons.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/shared/components/form_action_buttons.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"form_action_buttons.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/shared/components/form_action_buttons.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAI5E,KAAK,sBAAsB,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,qBAAqB,CAAC;IACrC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAGF,wBAAgB,iBAAiB,CAAC,EAChC,WAAW,EACX,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,eAAe,EACf,SAAS,EACT,UAAkB,GACnB,EAAE,sBAAsB,+BAwCxB"}
|
|
@@ -3,16 +3,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
// section: imports
|
|
4
4
|
import { CircleCheckBig, CircleX } from "lucide-react";
|
|
5
5
|
import { Button } from "../../../ui/button.js";
|
|
6
|
-
import
|
|
7
|
-
import { createPackageT } from "hazo_core/i18n";
|
|
8
|
-
const t = createPackageT("hazo_auth", en);
|
|
6
|
+
import { useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
9
7
|
// section: component
|
|
10
|
-
export function FormActionButtons({ submitLabel, cancelLabel
|
|
11
|
-
|
|
8
|
+
export function FormActionButtons({ submitLabel, cancelLabel, buttonPalette, isSubmitDisabled, onCancel, submitAriaLabel, cancelAriaLabel, className, hideCancel = false, }) {
|
|
9
|
+
const t = useAuthT();
|
|
10
|
+
const resolvedCancelLabel = cancelLabel !== null && cancelLabel !== void 0 ? cancelLabel : t("shared.cancel_button");
|
|
11
|
+
const resolvedSubmitAriaLabel = submitAriaLabel !== null && submitAriaLabel !== void 0 ? submitAriaLabel : t("shared.form_action.submit_aria_default");
|
|
12
|
+
const resolvedCancelAriaLabel = cancelAriaLabel !== null && cancelAriaLabel !== void 0 ? cancelAriaLabel : t("shared.form_action.cancel_aria_default");
|
|
13
|
+
return (_jsxs("div", { className: `cls_form_action_buttons mt-2 flex flex-wrap items-center justify-end gap-4 ${className !== null && className !== void 0 ? className : ""}`, children: [_jsxs(Button, { type: "submit", disabled: isSubmitDisabled, className: "cls_form_action_submit_button flex shrink-0 items-center gap-2", "aria-label": resolvedSubmitAriaLabel, style: {
|
|
12
14
|
backgroundColor: buttonPalette.submitBackground,
|
|
13
15
|
color: buttonPalette.submitText,
|
|
14
|
-
}, children: [_jsx(CircleCheckBig, { className: "h-4 w-4 shrink-0", "aria-hidden": "true" }), _jsx("span", { children: submitLabel })] }), !hideCancel && onCancel && (_jsxs(Button, { type: "button", variant: "outline", onClick: onCancel, className: "cls_form_action_cancel_button flex shrink-0 items-center gap-2", "aria-label":
|
|
16
|
+
}, children: [_jsx(CircleCheckBig, { className: "h-4 w-4 shrink-0", "aria-hidden": "true" }), _jsx("span", { children: submitLabel })] }), !hideCancel && onCancel && (_jsxs(Button, { type: "button", variant: "outline", onClick: onCancel, className: "cls_form_action_cancel_button flex shrink-0 items-center gap-2", "aria-label": resolvedCancelAriaLabel, style: {
|
|
15
17
|
borderColor: buttonPalette.cancelBorder,
|
|
16
18
|
color: buttonPalette.cancelText,
|
|
17
|
-
}, children: [_jsx(CircleX, { className: "h-4 w-4 shrink-0", "aria-hidden": "true" }), _jsx("span", { children:
|
|
19
|
+
}, children: [_jsx(CircleX, { className: "h-4 w-4 shrink-0", "aria-hidden": "true" }), _jsx("span", { children: resolvedCancelLabel })] }))] }));
|
|
18
20
|
}
|