hazo_auth 10.22.2 → 10.23.2
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/cli-src/lib/services/password_change_service.ts +4 -30
- package/cli-src/lib/utils/password_validator.ts +20 -12
- package/dist/admin-issues/plugin.client.d.ts.map +1 -1
- package/dist/admin-issues/plugin.client.js +7 -5
- package/dist/admin-issues/plugin.server.d.ts.map +1 -1
- package/dist/admin-issues/plugin.server.js +29 -18
- package/dist/components/layouts/create_firm/hooks/use_create_firm_form.d.ts.map +1 -1
- package/dist/components/layouts/create_firm/hooks/use_create_firm_form.js +10 -8
- package/dist/components/layouts/create_firm/index.d.ts +1 -1
- package/dist/components/layouts/create_firm/index.d.ts.map +1 -1
- package/dist/components/layouts/create_firm/index.js +15 -1
- package/dist/components/layouts/dev_lock/index.d.ts +1 -1
- package/dist/components/layouts/dev_lock/index.d.ts.map +1 -1
- package/dist/components/layouts/dev_lock/index.js +6 -2
- 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 +5 -20
- package/dist/components/layouts/my_settings/components/profile_picture_display.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_display.js +3 -1
- 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 +7 -27
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts +3 -1
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/hooks/use_my_settings.js +45 -64
- package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/index.js +2 -1
- package/dist/components/layouts/register/hooks/use_register_form.js +2 -2
- package/dist/components/layouts/scope_management/components/branding_editor.d.ts.map +1 -1
- package/dist/components/layouts/scope_management/components/branding_editor.js +16 -15
- package/dist/components/layouts/shared/components/profile_stamp.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/profile_stamp.js +7 -3
- package/dist/components/layouts/user_management/components/app_user_data_editor.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/app_user_data_editor.js +13 -12
- package/dist/components/layouts/user_management/components/roles_matrix.js +2 -2
- package/dist/components/layouts/user_management/components/user_signup_stats_cards.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/user_signup_stats_cards.js +11 -7
- package/dist/components/layouts/user_management/index.d.ts.map +1 -1
- package/dist/components/layouts/user_management/index.js +17 -17
- package/dist/components/otp/OTPRequestForm.js +1 -1
- package/dist/components/user_picker_select.d.ts +1 -1
- package/dist/components/user_picker_select.d.ts.map +1 -1
- package/dist/components/user_picker_select.js +6 -2
- package/dist/consent/cookie_consent_banner.d.ts.map +1 -1
- package/dist/consent/cookie_consent_banner.js +3 -1
- package/dist/consent/manage_modal.d.ts.map +1 -1
- package/dist/consent/manage_modal.js +3 -1
- package/dist/lib/services/password_change_service.d.ts.map +1 -1
- package/dist/lib/services/password_change_service.js +4 -26
- package/dist/lib/utils/password_validator.d.ts.map +1 -1
- package/dist/lib/utils/password_validator.js +17 -6
- package/dist/locales/en.json +193 -12
- package/dist/page_components/create_firm.d.ts.map +1 -1
- package/dist/page_components/create_firm.js +7 -4
- package/dist/page_components/my_settings.d.ts +1 -1
- package/dist/page_components/my_settings.d.ts.map +1 -1
- package/dist/page_components/my_settings.js +15 -1
- package/package.json +8 -8
|
@@ -6,6 +6,7 @@ import argon2 from "argon2";
|
|
|
6
6
|
import { get_password_requirements_config } from "../password_requirements_config.server.js";
|
|
7
7
|
import { send_template_email } from "./email_service.js";
|
|
8
8
|
import { create_app_logger } from "../app_logger.js";
|
|
9
|
+
import { validate_password } from "../utils/password_validator.js";
|
|
9
10
|
|
|
10
11
|
// section: types
|
|
11
12
|
export type PasswordChangeData = {
|
|
@@ -75,38 +76,11 @@ export async function change_password(
|
|
|
75
76
|
const password_requirements = get_password_requirements_config();
|
|
76
77
|
|
|
77
78
|
// Validate new password
|
|
78
|
-
|
|
79
|
+
const password_validation = validate_password(new_password, password_requirements);
|
|
80
|
+
if (!password_validation.valid) {
|
|
79
81
|
return {
|
|
80
82
|
success: false,
|
|
81
|
-
error:
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (password_requirements.require_uppercase && !/[A-Z]/.test(new_password)) {
|
|
86
|
-
return {
|
|
87
|
-
success: false,
|
|
88
|
-
error: "Password must contain at least one uppercase letter",
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (password_requirements.require_lowercase && !/[a-z]/.test(new_password)) {
|
|
93
|
-
return {
|
|
94
|
-
success: false,
|
|
95
|
-
error: "Password must contain at least one lowercase letter",
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (password_requirements.require_number && !/[0-9]/.test(new_password)) {
|
|
100
|
-
return {
|
|
101
|
-
success: false,
|
|
102
|
-
error: "Password must contain at least one number",
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (password_requirements.require_special && !/[^A-Za-z0-9]/.test(new_password)) {
|
|
107
|
-
return {
|
|
108
|
-
success: false,
|
|
109
|
-
error: "Password must contain at least one special character",
|
|
83
|
+
error: password_validation.errors[0],
|
|
110
84
|
};
|
|
111
85
|
}
|
|
112
86
|
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
// file_description: server-side password validation utility
|
|
2
2
|
//
|
|
3
|
-
// Message
|
|
4
|
-
// client-side `validatePassword()` in
|
|
5
|
-
// `components/layouts/shared/utils/validation.ts`
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
3
|
+
// Message strings are sourced directly from `../../locales/en.json` (single
|
|
4
|
+
// source of truth, shared with the client-side `validatePassword()` in
|
|
5
|
+
// `components/layouts/shared/utils/validation.ts`) rather than duplicated as
|
|
6
|
+
// hardcoded English literals — this mirrors the pattern already used by
|
|
7
|
+
// `src/strings/default_strings.ts` for importing locale JSON server-side.
|
|
8
|
+
// section: imports
|
|
9
|
+
import en from "../../locales/en.json" with { type: "json" };
|
|
10
|
+
|
|
11
|
+
// section: constants
|
|
12
|
+
const messages = en as Record<string, string>;
|
|
13
|
+
|
|
9
14
|
// section: types
|
|
10
15
|
export type PasswordRequirementOptions = {
|
|
11
16
|
minimum_length: number;
|
|
@@ -36,33 +41,36 @@ export function validate_password(
|
|
|
36
41
|
if (!password || password.trim().length === 0) {
|
|
37
42
|
return {
|
|
38
43
|
valid: false,
|
|
39
|
-
errors: ["
|
|
44
|
+
errors: [messages["validation.password_required"]],
|
|
40
45
|
};
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
if (password.length < requirements.minimum_length) {
|
|
44
49
|
errors.push(
|
|
45
|
-
|
|
50
|
+
messages["validation.password_too_short"].replace(
|
|
51
|
+
"{{count}}",
|
|
52
|
+
String(requirements.minimum_length)
|
|
53
|
+
)
|
|
46
54
|
);
|
|
47
55
|
}
|
|
48
56
|
|
|
49
57
|
if (requirements.require_uppercase && !/[A-Z]/.test(password)) {
|
|
50
|
-
errors.push("
|
|
58
|
+
errors.push(messages["validation.password_missing_uppercase"]);
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
if (requirements.require_lowercase && !/[a-z]/.test(password)) {
|
|
54
|
-
errors.push("
|
|
62
|
+
errors.push(messages["validation.password_missing_lowercase"]);
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
if (requirements.require_number && !/\d/.test(password)) {
|
|
58
|
-
errors.push("
|
|
66
|
+
errors.push(messages["validation.password_missing_number"]);
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
if (
|
|
62
70
|
requirements.require_special &&
|
|
63
71
|
!/[!@#$%^&*(),.?":{}|<>\-_+=\[\];'/\\]/.test(password)
|
|
64
72
|
) {
|
|
65
|
-
errors.push("
|
|
73
|
+
errors.push(messages["validation.password_missing_special"]);
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.client.d.ts","sourceRoot":"","sources":["../../src/admin-issues/plugin.client.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.client.d.ts","sourceRoot":"","sources":["../../src/admin-issues/plugin.client.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAIxC,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,UAAU,sBAAsB;IAC9B,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAClF;AAED,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,sBAAsB,qBAgJxE;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IAClD,gBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,sBAAsB,CAAC,KAAK,IAAI,CAAC;CACpG,GAAG,IAAI,CAEP"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
+
import { useAuthT } from "../contexts/hazo_auth_provider.js";
|
|
4
5
|
export function AuthIssueCard({ issue, onAction }) {
|
|
6
|
+
const t = useAuthT();
|
|
5
7
|
const [showGrant, setShowGrant] = useState(false);
|
|
6
8
|
const [showDeny, setShowDeny] = useState(false);
|
|
7
9
|
const [roleId, setRoleId] = useState('');
|
|
@@ -16,7 +18,7 @@ export function AuthIssueCard({ issue, onAction }) {
|
|
|
16
18
|
const isActive = issue.status === 'new' || issue.status === 'wip';
|
|
17
19
|
const handleGrant = async () => {
|
|
18
20
|
if (!roleId.trim()) {
|
|
19
|
-
setError(
|
|
21
|
+
setError(t("admin_issues.error.role_id_required"));
|
|
20
22
|
return;
|
|
21
23
|
}
|
|
22
24
|
setLoading(true);
|
|
@@ -27,7 +29,7 @@ export function AuthIssueCard({ issue, onAction }) {
|
|
|
27
29
|
}
|
|
28
30
|
catch (e) {
|
|
29
31
|
const err = e;
|
|
30
|
-
setError((err === null || err === void 0 ? void 0 : err.message) ||
|
|
32
|
+
setError((err === null || err === void 0 ? void 0 : err.message) || t("admin_issues.error.grant_failed"));
|
|
31
33
|
}
|
|
32
34
|
finally {
|
|
33
35
|
setLoading(false);
|
|
@@ -35,7 +37,7 @@ export function AuthIssueCard({ issue, onAction }) {
|
|
|
35
37
|
};
|
|
36
38
|
const handleDeny = async () => {
|
|
37
39
|
if (!denyReason.trim()) {
|
|
38
|
-
setError(
|
|
40
|
+
setError(t("admin_issues.error.reason_required"));
|
|
39
41
|
return;
|
|
40
42
|
}
|
|
41
43
|
setLoading(true);
|
|
@@ -46,13 +48,13 @@ export function AuthIssueCard({ issue, onAction }) {
|
|
|
46
48
|
}
|
|
47
49
|
catch (e) {
|
|
48
50
|
const err = e;
|
|
49
|
-
setError((err === null || err === void 0 ? void 0 : err.message) ||
|
|
51
|
+
setError((err === null || err === void 0 ? void 0 : err.message) || t("admin_issues.error.deny_failed"));
|
|
50
52
|
}
|
|
51
53
|
finally {
|
|
52
54
|
setLoading(false);
|
|
53
55
|
}
|
|
54
56
|
};
|
|
55
|
-
return (_jsxs("div", { className: "text-sm space-y-2", children: [_jsx("div", { className: "text-gray-700", children: issue.summary }), missingPerms.length > 0 && (_jsxs("div", { className: "text-xs text-gray-500", children: [_jsx("span", { className: "font-medium", children: "
|
|
57
|
+
return (_jsxs("div", { className: "text-sm space-y-2", children: [_jsx("div", { className: "text-gray-700", children: issue.summary }), missingPerms.length > 0 && (_jsxs("div", { className: "text-xs text-gray-500", children: [_jsx("span", { className: "font-medium", children: t("admin_issues.needs_label") }), missingPerms.map((p) => descriptions[p] || p).join(', ')] })), actionLabel && (_jsxs("div", { className: "text-xs text-gray-400", children: [_jsx("span", { className: "font-medium", children: t("admin_issues.tried_to_label") }), actionLabel] })), originUrl && (_jsxs("div", { className: "text-xs text-gray-400", children: [_jsx("span", { className: "font-medium", children: t("admin_issues.from_label") }), _jsx("span", { className: "font-mono", children: originUrl })] })), issue.occurrence_count > 1 && (_jsx("div", { className: "text-xs text-amber-600 font-medium", children: t("admin_issues.occurred_count", { count: issue.occurrence_count, date: new Date(issue.first_seen_at).toLocaleDateString() }) })), isActive && onAction && (_jsxs("div", { className: "flex gap-2 pt-1", children: [_jsx("button", { onClick: () => { setShowGrant(true); setShowDeny(false); setError(null); }, className: "px-2 py-1 text-xs bg-green-600 text-white rounded hover:bg-green-700", children: t("admin_issues.grant_button") }), _jsx("button", { onClick: () => { setShowDeny(true); setShowGrant(false); setError(null); }, className: "px-2 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700", children: t("admin_issues.deny_button") })] })), showGrant && (_jsxs("div", { className: "mt-2 p-2 border rounded bg-green-50 space-y-2", children: [_jsx("div", { className: "text-xs font-medium text-green-800", children: t("admin_issues.grant_form_heading") }), _jsx("input", { type: "text", value: roleId, onChange: (e) => setRoleId(e.target.value), placeholder: t("admin_issues.role_id_placeholder"), className: "w-full text-xs border rounded px-2 py-1" }), error && _jsx("div", { className: "text-xs text-red-600", children: error }), _jsxs("div", { className: "flex gap-2", children: [_jsx("button", { onClick: handleGrant, disabled: loading, className: "px-2 py-1 text-xs bg-green-600 text-white rounded disabled:opacity-50", children: loading ? t("admin_issues.granting") : t("admin_issues.confirm_grant") }), _jsx("button", { onClick: () => setShowGrant(false), className: "px-2 py-1 text-xs border rounded", children: t("shared.cancel_button") })] })] })), showDeny && (_jsxs("div", { className: "mt-2 p-2 border rounded bg-red-50 space-y-2", children: [_jsx("div", { className: "text-xs font-medium text-red-800", children: t("admin_issues.deny_form_heading") }), _jsx("textarea", { value: denyReason, onChange: (e) => setDenyReason(e.target.value), placeholder: t("admin_issues.deny_reason_placeholder"), rows: 2, className: "w-full text-xs border rounded px-2 py-1" }), error && _jsx("div", { className: "text-xs text-red-600", children: error }), _jsxs("div", { className: "flex gap-2", children: [_jsx("button", { onClick: handleDeny, disabled: loading, className: "px-2 py-1 text-xs bg-red-600 text-white rounded disabled:opacity-50", children: loading ? t("admin_issues.denying") : t("admin_issues.confirm_deny") }), _jsx("button", { onClick: () => setShowDeny(false), className: "px-2 py-1 text-xs border rounded", children: t("shared.cancel_button") })] })] })), issue.resolution && (_jsxs("div", { className: `text-xs mt-1 ${issue.resolution === 'granted' ? 'text-green-700' : 'text-red-700'}`, children: [issue.resolution === 'granted' ? t("admin_issues.resolution_granted") : t("admin_issues.resolution_denied"), issue.resolution_reason && `: ${issue.resolution_reason}`] }))] }));
|
|
56
58
|
}
|
|
57
59
|
/**
|
|
58
60
|
* Convenience registration function.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.server.d.ts","sourceRoot":"","sources":["../../src/admin-issues/plugin.server.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.server.d.ts","sourceRoot":"","sources":["../../src/admin-issues/plugin.server.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,CAAC;AAYrB,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,UAAU,mBAAmB;IAC3B,cAAc,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,UAAU,sBAAsB;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,UAAU,kBAAkB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,UAAU,mBAAmB;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,EAAE,MAAM,CAAC;IAC3B,GAAG,CACD,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACpC;AAED,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACtF,iBAAiB,CACf,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrD,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,qBAAqB,CACnB,KAAK,EAAE,gBAAgB,EACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,sBAAsB,GAC7B,kBAAkB,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB,EAAE,iBA8K9B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;CAC3C,GAAG,IAAI,CAEP"}
|
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
// file_description: hazo_auth issue type plugin for hazo_admin — auth permission access requests
|
|
2
2
|
import 'server-only';
|
|
3
3
|
import { createLogger } from 'hazo_core';
|
|
4
|
+
import { createPackageT } from 'hazo_core/i18n';
|
|
4
5
|
import { GLOBAL_ADMIN_PERMISSION } from '../lib/constants.js';
|
|
5
6
|
import { find_roles_with_permission } from '../lib/services/find_roles_with_permission.js';
|
|
7
|
+
import en from '../locales/en.json';
|
|
6
8
|
const log = createLogger('hazo_auth:auth-issues-plugin');
|
|
9
|
+
const t = createPackageT('hazo_auth', en);
|
|
7
10
|
export const authIssueTypeDef = {
|
|
8
11
|
typeKey: 'auth_permission',
|
|
9
|
-
label: '
|
|
12
|
+
label: t('admin_issues.server.type_label'),
|
|
10
13
|
buildDescriptor(payload) {
|
|
11
|
-
const actionLabel = payload.action_label || '
|
|
14
|
+
const actionLabel = payload.action_label || t('admin_issues.server.default_action_label');
|
|
12
15
|
const missingPerms = payload.missing_permissions || [];
|
|
13
16
|
const descriptions = payload.permission_descriptions || {};
|
|
14
17
|
const permLabel = missingPerms.map((p) => descriptions[p] || p).join(', ');
|
|
18
|
+
const permissions = permLabel || missingPerms.join(', ');
|
|
15
19
|
return {
|
|
16
|
-
title:
|
|
17
|
-
summary:
|
|
20
|
+
title: t('admin_issues.server.descriptor_title', { permissions }),
|
|
21
|
+
summary: t('admin_issues.server.descriptor_summary', {
|
|
22
|
+
action: actionLabel,
|
|
23
|
+
plural: missingPerms.length > 1 ? 's' : '',
|
|
24
|
+
permissions,
|
|
25
|
+
}),
|
|
18
26
|
};
|
|
19
27
|
},
|
|
20
28
|
async resolveRecipients(issue, ctx) {
|
|
@@ -71,7 +79,7 @@ export const authIssueTypeDef = {
|
|
|
71
79
|
actions: [
|
|
72
80
|
{
|
|
73
81
|
key: 'grant',
|
|
74
|
-
label: '
|
|
82
|
+
label: t('admin_issues.server.action_grant_label'),
|
|
75
83
|
requiredPermission: 'admin_user_scope_assignment',
|
|
76
84
|
async run(issue, params, ctx) {
|
|
77
85
|
const { role_id } = params;
|
|
@@ -81,12 +89,15 @@ export const authIssueTypeDef = {
|
|
|
81
89
|
const missingPerms = issue.payload.missing_permissions || [];
|
|
82
90
|
const permission = missingPerms[0];
|
|
83
91
|
if (!permission)
|
|
84
|
-
return { success: false, message: '
|
|
92
|
+
return { success: false, message: t('admin_issues.server.error_no_missing_permission') };
|
|
85
93
|
const roles = await find_roles_with_permission(adapter, issue.scope_id, permission);
|
|
86
94
|
if (roles.length === 0) {
|
|
87
95
|
return {
|
|
88
96
|
success: false,
|
|
89
|
-
message:
|
|
97
|
+
message: t('admin_issues.server.error_no_role_grants_permission', {
|
|
98
|
+
scope_id: issue.scope_id,
|
|
99
|
+
permission,
|
|
100
|
+
}),
|
|
90
101
|
data: {
|
|
91
102
|
noRolesFound: true,
|
|
92
103
|
permission,
|
|
@@ -96,7 +107,7 @@ export const authIssueTypeDef = {
|
|
|
96
107
|
}
|
|
97
108
|
return {
|
|
98
109
|
success: false,
|
|
99
|
-
message: '
|
|
110
|
+
message: t('admin_issues.server.error_select_role'),
|
|
100
111
|
data: { availableRoles: roles },
|
|
101
112
|
};
|
|
102
113
|
}
|
|
@@ -109,25 +120,25 @@ export const authIssueTypeDef = {
|
|
|
109
120
|
role_id: role_id,
|
|
110
121
|
});
|
|
111
122
|
if (!(result === null || result === void 0 ? void 0 : result.success)) {
|
|
112
|
-
return { success: false, message: (result === null || result === void 0 ? void 0 : result.error) || '
|
|
123
|
+
return { success: false, message: (result === null || result === void 0 ? void 0 : result.error) || t('admin_issues.server.error_assign_scope_failed') };
|
|
113
124
|
}
|
|
114
125
|
return {
|
|
115
126
|
success: true,
|
|
116
|
-
message: '
|
|
127
|
+
message: t('admin_issues.server.success_granted'),
|
|
117
128
|
data: { roleId: role_id },
|
|
118
129
|
};
|
|
119
130
|
},
|
|
120
131
|
},
|
|
121
132
|
{
|
|
122
133
|
key: 'deny',
|
|
123
|
-
label: '
|
|
134
|
+
label: t('admin_issues.server.action_deny_label'),
|
|
124
135
|
requiredPermission: 'admin_issue_triage',
|
|
125
136
|
async run(_issue, params, _ctx) {
|
|
126
137
|
const { reason } = params;
|
|
127
138
|
if (!reason || typeof reason !== 'string' || reason.trim().length === 0) {
|
|
128
|
-
return { success: false, message: '
|
|
139
|
+
return { success: false, message: t('admin_issues.server.error_reason_required') };
|
|
129
140
|
}
|
|
130
|
-
return { success: true, message: '
|
|
141
|
+
return { success: true, message: t('admin_issues.server.success_denied'), data: { reason } };
|
|
131
142
|
},
|
|
132
143
|
},
|
|
133
144
|
],
|
|
@@ -140,9 +151,9 @@ export const authIssueTypeDef = {
|
|
|
140
151
|
const permLabel = missingPerms.map((p) => descriptions[p] || p).join(', ');
|
|
141
152
|
if (actionKey === 'grant') {
|
|
142
153
|
const roleId = (_a = result.data) === null || _a === void 0 ? void 0 : _a.roleId;
|
|
143
|
-
const body =
|
|
154
|
+
const body = `${t('admin_issues.server.notice_grant_body', { permissions: permLabel })}${originUrl ? t('admin_issues.server.notice_grant_return_hint') : ''}`;
|
|
144
155
|
return {
|
|
145
|
-
subject: '
|
|
156
|
+
subject: t('admin_issues.server.notice_grant_subject'),
|
|
146
157
|
body,
|
|
147
158
|
deep_link: originUrl,
|
|
148
159
|
payload: { resolution: 'granted', role_id: roleId },
|
|
@@ -150,10 +161,10 @@ export const authIssueTypeDef = {
|
|
|
150
161
|
}
|
|
151
162
|
const reason = ((_b = result.data) === null || _b === void 0 ? void 0 : _b.reason) ||
|
|
152
163
|
issue.resolution_reason ||
|
|
153
|
-
'
|
|
164
|
+
t('admin_issues.server.notice_no_reason');
|
|
154
165
|
return {
|
|
155
|
-
subject: '
|
|
156
|
-
body:
|
|
166
|
+
subject: t('admin_issues.server.notice_deny_subject'),
|
|
167
|
+
body: t('admin_issues.server.notice_deny_body', { permissions: permLabel, reason }),
|
|
157
168
|
payload: { resolution: 'denied', reason },
|
|
158
169
|
};
|
|
159
170
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_create_firm_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/create_firm/hooks/use_create_firm_form.ts"],"names":[],"mappings":"AAIA,OAAO,EAAqD,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"use_create_firm_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/create_firm/hooks/use_create_firm_form.ts"],"names":[],"mappings":"AAIA,OAAO,EAAqD,SAAS,EAAE,MAAM,OAAO,CAAC;AAIrF,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S,CAAC,gBAAgB,CAAC,CAAC;IAC/C,8DAA8D;IAC9D,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACnD,oEAAoE;IACpE,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC;AAGF,wBAAgB,oBAAoB,CAClC,OAAO,GAAE,wBAA6B,GACrC,uBAAuB,CAuQzB"}
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
// section: imports
|
|
4
4
|
import { useState, useCallback, useRef, useEffect, useMemo } from "react";
|
|
5
|
+
import { useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
5
6
|
// section: hook
|
|
6
7
|
export function use_create_firm_form(options = {}) {
|
|
7
8
|
const { default_org_structure = "Headquarters", onSuccess, redirectRoute = "/", apiBasePath = "/api/hazo_auth", logger, } = options;
|
|
9
|
+
const t = useAuthT();
|
|
8
10
|
const [values, setValues] = useState({
|
|
9
11
|
firm_name: "",
|
|
10
12
|
org_structure: default_org_structure,
|
|
@@ -120,20 +122,20 @@ export function use_create_firm_form(options = {}) {
|
|
|
120
122
|
const validateForm = useCallback(() => {
|
|
121
123
|
const newErrors = {};
|
|
122
124
|
if (!values.firm_name.trim()) {
|
|
123
|
-
newErrors.firm_name = "
|
|
125
|
+
newErrors.firm_name = t("create_firm.validation.firm_name_required");
|
|
124
126
|
}
|
|
125
127
|
else if (values.firm_name.length > 100) {
|
|
126
|
-
newErrors.firm_name = "
|
|
128
|
+
newErrors.firm_name = t("create_firm.validation.firm_name_max_length");
|
|
127
129
|
}
|
|
128
130
|
if (!values.org_structure.trim()) {
|
|
129
|
-
newErrors.org_structure = "
|
|
131
|
+
newErrors.org_structure = t("create_firm.validation.org_structure_required");
|
|
130
132
|
}
|
|
131
133
|
else if (values.org_structure.length > 50) {
|
|
132
|
-
newErrors.org_structure = "
|
|
134
|
+
newErrors.org_structure = t("create_firm.validation.org_structure_max_length");
|
|
133
135
|
}
|
|
134
136
|
setErrors(newErrors);
|
|
135
137
|
return Object.keys(newErrors).length === 0;
|
|
136
|
-
}, [values]);
|
|
138
|
+
}, [values, t]);
|
|
137
139
|
const handleSubmit = useCallback(async (e) => {
|
|
138
140
|
var _a, _b;
|
|
139
141
|
e.preventDefault();
|
|
@@ -155,7 +157,7 @@ export function use_create_firm_form(options = {}) {
|
|
|
155
157
|
});
|
|
156
158
|
const data = await response.json();
|
|
157
159
|
if (!response.ok) {
|
|
158
|
-
setErrors({ form: data.error || "
|
|
160
|
+
setErrors({ form: data.error || t("create_firm.error.create_failed") });
|
|
159
161
|
logger === null || logger === void 0 ? void 0 : logger.error("create_firm_form_error", {
|
|
160
162
|
error: data.error,
|
|
161
163
|
status: response.status,
|
|
@@ -177,7 +179,7 @@ export function use_create_firm_form(options = {}) {
|
|
|
177
179
|
}
|
|
178
180
|
catch (error) {
|
|
179
181
|
const error_message = error instanceof Error ? error.message : "Unknown error";
|
|
180
|
-
setErrors({ form: "
|
|
182
|
+
setErrors({ form: t("create_firm.error.unexpected") });
|
|
181
183
|
logger === null || logger === void 0 ? void 0 : logger.error("create_firm_form_error", {
|
|
182
184
|
error: error_message,
|
|
183
185
|
});
|
|
@@ -185,7 +187,7 @@ export function use_create_firm_form(options = {}) {
|
|
|
185
187
|
finally {
|
|
186
188
|
setIsSubmitting(false);
|
|
187
189
|
}
|
|
188
|
-
}, [values, validateForm, onSuccess, redirectRoute, apiBasePath, logger]);
|
|
190
|
+
}, [values, validateForm, onSuccess, redirectRoute, apiBasePath, logger, t]);
|
|
189
191
|
// Calculate disabled state using both React state AND refs as fallback
|
|
190
192
|
// This handles cases where DOM is populated but React state hasn't caught up
|
|
191
193
|
// (browser autocomplete, password managers, form restoration, etc.)
|
|
@@ -58,6 +58,6 @@ export type CreateFirmLayoutProps = {
|
|
|
58
58
|
error: (message: string, data?: Record<string, unknown>) => void;
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
|
-
export default function CreateFirmLayout({ image_src, keyword, keyword_lower, verb, image_alt, image_background_color, banner_body, heading, sub_heading, firm_name_label, firm_name_placeholder, org_structure_label, org_structure_placeholder, default_org_structure, show_org_structure, submit_button_label, success_message, redirect_route, apiBasePath, onSuccess, button_colors, logger, }: CreateFirmLayoutProps): React.JSX.Element;
|
|
61
|
+
export default function CreateFirmLayout({ image_src, keyword: keywordProp, keyword_lower: keywordLowerProp, verb: verbProp, image_alt: imageAltProp, image_background_color, banner_body: bannerBodyProp, heading: headingProp, sub_heading: subHeadingProp, firm_name_label: firmNameLabelProp, firm_name_placeholder: firmNamePlaceholderProp, org_structure_label: orgStructureLabelProp, org_structure_placeholder: orgStructurePlaceholderProp, default_org_structure: defaultOrgStructureProp, show_org_structure, submit_button_label: submitButtonLabelProp, success_message: successMessageProp, redirect_route, apiBasePath, onSuccess, button_colors, logger, }: CreateFirmLayoutProps): React.JSX.Element;
|
|
62
62
|
export { CreateFirmLayout };
|
|
63
63
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/create_firm/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAOlD,OAAO,EACL,KAAK,sBAAsB,EAC5B,MAAM,uCAAuC,CAAC;AAQ/C,MAAM,MAAM,qBAAqB,GAAG;IAClC,sCAAsC;IACtC,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC;IACpC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iDAAiD;IACjD,WA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AE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,6BAA6B;IAC7B,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,2BAA2B;IAC3B,MAAM,CAAC,EAAE;QACP,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QAChE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;KAClE,CAAC;CACH,CAAC;AAGF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,SAAS,EACT,OAAO,EAAE,WAAW,EACpB,aAAa,EAAE,gBAAgB,EAC/B,IAAI,EAAE,QAAQ,EACd,SAAS,EAAE,YAAY,EACvB,sBAAkC,EAClC,WAAW,EAAE,cAAc,EAC3B,OAAO,EAAE,WAAW,EACpB,WAAW,EAAE,cAAc,EAC3B,eAAe,EAAE,iBAAiB,EAClC,qBAAqB,EAAE,uBAAuB,EAC9C,mBAAmB,EAAE,qBAAqB,EAC1C,yBAAyB,EAAE,2BAA2B,EACtD,qBAAqB,EAAE,uBAAuB,EAC9C,kBAAyB,EACzB,mBAAmB,EAAE,qBAAqB,EAC1C,eAAe,EAAE,kBAAkB,EACnC,cAAoB,EACpB,WAAW,EACX,SAAS,EACT,aAAa,EACb,MAAM,GACP,EAAE,qBAAqB,qBAyKvB;AAGD,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -11,10 +11,24 @@ import { CheckCircle, Building2 } from "lucide-react";
|
|
|
11
11
|
import { use_create_firm_form, } from "./hooks/use_create_firm_form.js";
|
|
12
12
|
import { useHazoAuthConfig, useAuthT } from "../../../contexts/hazo_auth_provider.js";
|
|
13
13
|
// section: component
|
|
14
|
-
export default function CreateFirmLayout({ image_src, keyword
|
|
14
|
+
export default function CreateFirmLayout({ image_src, keyword: keywordProp, keyword_lower: keywordLowerProp, verb: verbProp, image_alt: imageAltProp, image_background_color = "#f1f5f9", banner_body: bannerBodyProp, heading: headingProp, sub_heading: subHeadingProp, firm_name_label: firmNameLabelProp, firm_name_placeholder: firmNamePlaceholderProp, org_structure_label: orgStructureLabelProp, org_structure_placeholder: orgStructurePlaceholderProp, default_org_structure: defaultOrgStructureProp, show_org_structure = true, submit_button_label: submitButtonLabelProp, success_message: successMessageProp, redirect_route = "/", apiBasePath, onSuccess, button_colors, logger, }) {
|
|
15
15
|
const { apiBasePath: contextApiBasePath } = useHazoAuthConfig();
|
|
16
16
|
const t = useAuthT();
|
|
17
17
|
const resolvedApiBasePath = apiBasePath || contextApiBasePath;
|
|
18
|
+
const keyword = keywordProp !== null && keywordProp !== void 0 ? keywordProp : t("create_firm.keyword");
|
|
19
|
+
const keyword_lower = keywordLowerProp !== null && keywordLowerProp !== void 0 ? keywordLowerProp : t("create_firm.keyword_lower");
|
|
20
|
+
const verb = verbProp !== null && verbProp !== void 0 ? verbProp : t("create_firm.verb");
|
|
21
|
+
const image_alt = imageAltProp !== null && imageAltProp !== void 0 ? imageAltProp : `${verb} your ${keyword_lower}`;
|
|
22
|
+
const banner_body = bannerBodyProp !== null && bannerBodyProp !== void 0 ? bannerBodyProp : t("create_firm.banner_body", { verb, keyword_lower });
|
|
23
|
+
const heading = headingProp !== null && headingProp !== void 0 ? headingProp : `${verb} Your ${keyword}`;
|
|
24
|
+
const sub_heading = subHeadingProp !== null && subHeadingProp !== void 0 ? subHeadingProp : t("create_firm.subtitle");
|
|
25
|
+
const firm_name_label = firmNameLabelProp !== null && firmNameLabelProp !== void 0 ? firmNameLabelProp : `${keyword} Name`;
|
|
26
|
+
const firm_name_placeholder = firmNamePlaceholderProp !== null && firmNamePlaceholderProp !== void 0 ? firmNamePlaceholderProp : `Enter your ${keyword_lower} name`;
|
|
27
|
+
const org_structure_label = orgStructureLabelProp !== null && orgStructureLabelProp !== void 0 ? orgStructureLabelProp : t("create_firm.org_structure_label");
|
|
28
|
+
const org_structure_placeholder = orgStructurePlaceholderProp !== null && orgStructurePlaceholderProp !== void 0 ? orgStructurePlaceholderProp : t("create_firm.org_structure_placeholder");
|
|
29
|
+
const default_org_structure = defaultOrgStructureProp !== null && defaultOrgStructureProp !== void 0 ? defaultOrgStructureProp : t("create_firm.default_org_structure");
|
|
30
|
+
const submit_button_label = submitButtonLabelProp !== null && submitButtonLabelProp !== void 0 ? submitButtonLabelProp : `${verb} ${keyword}`;
|
|
31
|
+
const success_message = successMessageProp !== null && successMessageProp !== void 0 ? successMessageProp : `Your ${keyword_lower} has been created successfully!`;
|
|
18
32
|
const form = use_create_firm_form({
|
|
19
33
|
default_org_structure,
|
|
20
34
|
onSuccess,
|
|
@@ -24,6 +24,6 @@ export type DevLockLayoutProps = {
|
|
|
24
24
|
/** Callback when unlock is successful */
|
|
25
25
|
onUnlock?: () => void;
|
|
26
26
|
};
|
|
27
|
-
export default function DevLockLayout({ background_color, logo_path, logo_width, logo_height, application_name, limited_access_text, password_placeholder, submit_button_text, error_message, text_color, accent_color, onUnlock, }: DevLockLayoutProps): import("react").JSX.Element;
|
|
27
|
+
export default function DevLockLayout({ background_color, logo_path, logo_width, logo_height, application_name, limited_access_text: limitedAccessTextProp, password_placeholder: passwordPlaceholderProp, submit_button_text: submitButtonTextProp, error_message: errorMessageProp, text_color, accent_color, onUnlock, }: DevLockLayoutProps): import("react").JSX.Element;
|
|
28
28
|
export { DevLockLayout };
|
|
29
29
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/dev_lock/index.tsx"],"names":[],"mappings":"AAcA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,kDAAkD;IAClD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0CAA0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CAAC,EAAE,MAAM,CAAC;IACvB,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAGF,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,gBAA4B,EAC5B,SAAc,EACd,UAAgB,EAChB,WAAiB,EACjB,gBAAqB,EACrB,mBAAmB,EAAE,qBAAqB,EAC1C,oBAAoB,EAAE,uBAAuB,EAC7C,kBAAkB,EAAE,oBAAoB,EACxC,aAAa,EAAE,gBAAgB,EAC/B,UAAsB,EACtB,YAAwB,EACxB,QAAQ,GACT,EAAE,kBAAkB,+BA2JpB;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -11,13 +11,17 @@ import { Button } from "../../ui/button.js";
|
|
|
11
11
|
import { Lock, AlertCircle, Loader2 } from "lucide-react";
|
|
12
12
|
import { useAuthT } from "../../../contexts/hazo_auth_provider.js";
|
|
13
13
|
// section: component
|
|
14
|
-
export default function DevLockLayout({ background_color = "#000000", logo_path = "", logo_width = 120, logo_height = 120, application_name = "", limited_access_text
|
|
14
|
+
export default function DevLockLayout({ background_color = "#000000", logo_path = "", logo_width = 120, logo_height = 120, application_name = "", limited_access_text: limitedAccessTextProp, password_placeholder: passwordPlaceholderProp, submit_button_text: submitButtonTextProp, error_message: errorMessageProp, text_color = "#ffffff", accent_color = "#3b82f6", onUnlock, }) {
|
|
15
15
|
// Only show logo if logo_path is configured (non-empty)
|
|
16
16
|
const showLogo = logo_path !== "";
|
|
17
17
|
const [password, setPassword] = useState("");
|
|
18
18
|
const [error, setError] = useState(null);
|
|
19
19
|
const [isLoading, setIsLoading] = useState(false);
|
|
20
20
|
const t = useAuthT();
|
|
21
|
+
const limited_access_text = limitedAccessTextProp !== null && limitedAccessTextProp !== void 0 ? limitedAccessTextProp : t("dev_lock.limited_access");
|
|
22
|
+
const password_placeholder = passwordPlaceholderProp !== null && passwordPlaceholderProp !== void 0 ? passwordPlaceholderProp : t("dev_lock.password_placeholder");
|
|
23
|
+
const submit_button_text = submitButtonTextProp !== null && submitButtonTextProp !== void 0 ? submitButtonTextProp : t("dev_lock.unlock_button");
|
|
24
|
+
const error_message = errorMessageProp !== null && errorMessageProp !== void 0 ? errorMessageProp : t("dev_lock.incorrect_password");
|
|
21
25
|
const handleSubmit = useCallback(async (e) => {
|
|
22
26
|
e.preventDefault();
|
|
23
27
|
setError(null);
|
|
@@ -61,7 +65,7 @@ export default function DevLockLayout({ background_color = "#000000", logo_path
|
|
|
61
65
|
setError(null);
|
|
62
66
|
}
|
|
63
67
|
}, [error]);
|
|
64
|
-
return (_jsx("div", { className: "cls_dev_lock_layout min-h-screen flex flex-col items-center justify-center p-4", style: { backgroundColor: background_color }, children: _jsxs("div", { className: "cls_dev_lock_container flex flex-col items-center gap-6 max-w-sm w-full", children: [showLogo && (_jsx("div", { className: "cls_dev_lock_logo", children: _jsx(Image, { src: logo_path, alt: "
|
|
68
|
+
return (_jsx("div", { className: "cls_dev_lock_layout min-h-screen flex flex-col items-center justify-center p-4", style: { backgroundColor: background_color }, children: _jsxs("div", { className: "cls_dev_lock_container flex flex-col items-center gap-6 max-w-sm w-full", children: [showLogo && (_jsx("div", { className: "cls_dev_lock_logo", children: _jsx(Image, { src: logo_path, alt: t("dev_lock.logo_alt"), width: logo_width, height: logo_height, className: "object-contain", priority: true }) })), application_name && (_jsx("h1", { className: "cls_dev_lock_app_name text-2xl font-bold text-center", style: { color: text_color }, children: application_name })), _jsxs("div", { className: "cls_dev_lock_header flex items-center gap-2", children: [_jsx(Lock, { className: "w-5 h-5", style: { color: text_color } }), _jsx("span", { className: "cls_dev_lock_text text-sm font-medium uppercase tracking-wider", style: { color: text_color, opacity: 0.8 }, children: limited_access_text })] }), _jsxs("form", { onSubmit: handleSubmit, className: "cls_dev_lock_form flex flex-col gap-4 w-full", children: [_jsx("div", { className: "cls_dev_lock_input_wrapper relative", children: _jsx(Input, { type: "password", value: password, onChange: handlePasswordChange, placeholder: password_placeholder, className: "cls_dev_lock_input h-12 bg-white/10 border-white/20 text-white placeholder:text-white/50 focus:border-white/40 focus:ring-white/20", disabled: isLoading, autoFocus: true, autoComplete: "current-password" }) }), error && (_jsxs("div", { className: "cls_dev_lock_error flex items-center gap-2 text-sm", style: { color: "#ef4444" }, children: [_jsx(AlertCircle, { className: "w-4 h-4 flex-shrink-0" }), _jsx("span", { children: error })] })), _jsx(Button, { type: "submit", className: "cls_dev_lock_button h-12 font-medium transition-colors", style: {
|
|
65
69
|
backgroundColor: accent_color,
|
|
66
70
|
color: "#ffffff",
|
|
67
71
|
}, disabled: isLoading || !password, children: isLoading ? (_jsxs(_Fragment, { children: [_jsx(Loader2, { className: "w-4 h-4 animate-spin mr-2" }), t("dev_lock.verifying")] })) : (submit_button_text) })] })] }) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password_change_dialog.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/password_change_dialog.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"password_change_dialog.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/password_change_dialog.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAK3F,MAAM,MAAM,aAAa,GAAG;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,oBAAoB,EAAE,0BAA0B,CAAC;IACjD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAGF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,GAClB,EAAE,yBAAyB,+BAiO3B"}
|
|
@@ -9,6 +9,7 @@ import { Button } from "../../../ui/button.js";
|
|
|
9
9
|
import { PasswordField } from "../../shared/components/password_field.js";
|
|
10
10
|
import { FormFieldWrapper } from "../../shared/components/form_field_wrapper.js";
|
|
11
11
|
import { useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
12
|
+
import { validatePassword as validateSharedPassword } from "../../shared/utils/validation.js";
|
|
12
13
|
// section: component
|
|
13
14
|
/**
|
|
14
15
|
* Dialog component for changing password
|
|
@@ -33,26 +34,10 @@ export function PasswordChangeDialog({ open, onOpenChange, onSave, passwordRequi
|
|
|
33
34
|
const [errors, setErrors] = useState({});
|
|
34
35
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
35
36
|
const validatePassword = (password) => {
|
|
36
|
-
if (!password
|
|
37
|
-
return t("
|
|
37
|
+
if (!password) {
|
|
38
|
+
return t("validation.password_required");
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
if (passwordRequirements.require_uppercase && !/[A-Z]/.test(password)) {
|
|
41
|
-
errors.push(t("my_settings.set_password.validation.uppercase_item"));
|
|
42
|
-
}
|
|
43
|
-
if (passwordRequirements.require_lowercase && !/[a-z]/.test(password)) {
|
|
44
|
-
errors.push(t("my_settings.set_password.validation.lowercase_item"));
|
|
45
|
-
}
|
|
46
|
-
if (passwordRequirements.require_number && !/[0-9]/.test(password)) {
|
|
47
|
-
errors.push(t("my_settings.set_password.validation.number_item"));
|
|
48
|
-
}
|
|
49
|
-
if (passwordRequirements.require_special && !/[^A-Za-z0-9]/.test(password)) {
|
|
50
|
-
errors.push(t("my_settings.set_password.validation.special_item"));
|
|
51
|
-
}
|
|
52
|
-
if (errors.length > 0) {
|
|
53
|
-
return t("my_settings.set_password.validation.missing_requirements", { list: errors.join(", ") });
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
40
|
+
return validateSharedPassword(password, passwordRequirements, t);
|
|
56
41
|
};
|
|
57
42
|
const validateForm = () => {
|
|
58
43
|
const newErrors = {};
|
|
@@ -67,7 +52,7 @@ export function PasswordChangeDialog({ open, onOpenChange, onSave, passwordRequi
|
|
|
67
52
|
newErrors.confirmPassword = t("my_settings.set_password.validation.confirm_required");
|
|
68
53
|
}
|
|
69
54
|
else if (newPassword !== confirmPassword) {
|
|
70
|
-
newErrors.confirmPassword = t("
|
|
55
|
+
newErrors.confirmPassword = t("validation.passwords_do_not_match");
|
|
71
56
|
}
|
|
72
57
|
setErrors(newErrors);
|
|
73
58
|
return Object.keys(newErrors).length === 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile_picture_display.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/profile_picture_display.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"profile_picture_display.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/profile_picture_display.tsx"],"names":[],"mappings":"AAWA,MAAM,MAAM,0BAA0B,GAAG;IACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAGF;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,iBAAiB,EACjB,IAAI,EACJ,KAAK,EACL,MAAM,EACN,QAAgB,GACjB,EAAE,0BAA0B,+BAiC5B"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
5
|
// section: imports
|
|
6
6
|
import { Avatar, AvatarImage, AvatarFallback } from "../../../ui/avatar.js";
|
|
7
|
+
import { useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
7
8
|
// section: component
|
|
8
9
|
/**
|
|
9
10
|
* Profile picture display component
|
|
@@ -13,6 +14,7 @@ import { Avatar, AvatarImage, AvatarFallback } from "../../../ui/avatar.js";
|
|
|
13
14
|
* @returns Profile picture display component
|
|
14
15
|
*/
|
|
15
16
|
export function ProfilePictureDisplay({ profilePictureUrl, name, email, onEdit, disabled = false, }) {
|
|
17
|
+
const t = useAuthT();
|
|
16
18
|
// Get initials from name or email
|
|
17
19
|
const getInitials = () => {
|
|
18
20
|
var _a, _b;
|
|
@@ -29,5 +31,5 @@ export function ProfilePictureDisplay({ profilePictureUrl, name, email, onEdit,
|
|
|
29
31
|
return "?";
|
|
30
32
|
};
|
|
31
33
|
const initials = getInitials();
|
|
32
|
-
return (_jsx("div", { className: "cls_profile_picture_display", children: _jsxs(Avatar, { className: "cls_profile_picture_display_avatar h-32 w-32", children: [_jsx(AvatarImage, { src: profilePictureUrl, alt: name ?
|
|
34
|
+
return (_jsx("div", { className: "cls_profile_picture_display", children: _jsxs(Avatar, { className: "cls_profile_picture_display_avatar h-32 w-32", children: [_jsx(AvatarImage, { src: profilePictureUrl, alt: name ? t("shared.avatar.alt_named", { name }) : t("shared.avatar.alt_default"), className: "cls_profile_picture_display_image" }), _jsx(AvatarFallback, { className: "cls_profile_picture_display_fallback bg-[var(--hazo-bg-emphasis)] text-[var(--hazo-text-muted)] text-3xl", children: initials })] }) }));
|
|
33
35
|
}
|