hazo_auth 10.22.2 → 10.23.1
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/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/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 +25 -44
- 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/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/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/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/otp/OTPRequestForm.js +1 -1
- 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 +96 -12
- package/package.json +6 -6
|
@@ -10,7 +10,7 @@ import { Label } from "../../../ui/label.js";
|
|
|
10
10
|
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "../../../ui/dialog.js";
|
|
11
11
|
import { Loader2, Upload, Trash2, CircleCheck, CircleX, Image as ImageIcon, Palette, Plus, } from "lucide-react";
|
|
12
12
|
import { toast } from "sonner";
|
|
13
|
-
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider.js";
|
|
13
|
+
import { useHazoAuthConfig, useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
14
14
|
// section: helpers
|
|
15
15
|
function isValidHexColor(color) {
|
|
16
16
|
return /^#[0-9A-Fa-f]{6}$/.test(color);
|
|
@@ -19,6 +19,7 @@ function isValidHexColor(color) {
|
|
|
19
19
|
export function BrandingEditor({ scopeId, scopeName, isOpen, onClose, onSave, initialBranding, }) {
|
|
20
20
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
21
21
|
const { apiBasePath } = useHazoAuthConfig();
|
|
22
|
+
const t = useAuthT();
|
|
22
23
|
// State
|
|
23
24
|
const [loading, setLoading] = useState(false);
|
|
24
25
|
const [saving, setSaving] = useState(false);
|
|
@@ -68,7 +69,7 @@ export function BrandingEditor({ scopeId, scopeName, isOpen, onClose, onSave, in
|
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
catch (error) {
|
|
71
|
-
toast.error("
|
|
72
|
+
toast.error(t("branding.toast.load_failed"));
|
|
72
73
|
}
|
|
73
74
|
finally {
|
|
74
75
|
setLoading(false);
|
|
@@ -88,14 +89,14 @@ export function BrandingEditor({ scopeId, scopeName, isOpen, onClose, onSave, in
|
|
|
88
89
|
const data = await response.json();
|
|
89
90
|
if (data.success) {
|
|
90
91
|
setLogoUrl(data.logo_url);
|
|
91
|
-
toast.success("
|
|
92
|
+
toast.success(t("branding.toast.upload_success"));
|
|
92
93
|
}
|
|
93
94
|
else {
|
|
94
|
-
toast.error(data.error || "
|
|
95
|
+
toast.error(data.error || t("branding.toast.upload_failed"));
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
catch (error) {
|
|
98
|
-
toast.error("
|
|
99
|
+
toast.error(t("branding.toast.upload_failed"));
|
|
99
100
|
}
|
|
100
101
|
finally {
|
|
101
102
|
setUploading(false);
|
|
@@ -118,11 +119,11 @@ export function BrandingEditor({ scopeId, scopeName, isOpen, onClose, onSave, in
|
|
|
118
119
|
const handleSave = async () => {
|
|
119
120
|
// Validate colors
|
|
120
121
|
if (primaryColor && !isValidHexColor(primaryColor)) {
|
|
121
|
-
toast.error(
|
|
122
|
+
toast.error(t("branding.toast.invalid_primary_color"));
|
|
122
123
|
return;
|
|
123
124
|
}
|
|
124
125
|
if (secondaryColor && !isValidHexColor(secondaryColor)) {
|
|
125
|
-
toast.error(
|
|
126
|
+
toast.error(t("branding.toast.invalid_secondary_color"));
|
|
126
127
|
return;
|
|
127
128
|
}
|
|
128
129
|
setSaving(true);
|
|
@@ -158,16 +159,16 @@ export function BrandingEditor({ scopeId, scopeName, isOpen, onClose, onSave, in
|
|
|
158
159
|
});
|
|
159
160
|
const data = await response.json();
|
|
160
161
|
if (data.success) {
|
|
161
|
-
toast.success("
|
|
162
|
+
toast.success(t("branding.toast.save_success"));
|
|
162
163
|
onSave === null || onSave === void 0 ? void 0 : onSave(hasValues ? branding : null);
|
|
163
164
|
onClose();
|
|
164
165
|
}
|
|
165
166
|
else {
|
|
166
|
-
toast.error(data.error || "
|
|
167
|
+
toast.error(data.error || t("branding.toast.save_failed"));
|
|
167
168
|
}
|
|
168
169
|
}
|
|
169
170
|
catch (error) {
|
|
170
|
-
toast.error("
|
|
171
|
+
toast.error(t("branding.toast.save_failed"));
|
|
171
172
|
}
|
|
172
173
|
finally {
|
|
173
174
|
setSaving(false);
|
|
@@ -191,15 +192,15 @@ export function BrandingEditor({ scopeId, scopeName, isOpen, onClose, onSave, in
|
|
|
191
192
|
setPublicCopyright("");
|
|
192
193
|
setPublicLinks([]);
|
|
193
194
|
setAppCopyright("");
|
|
194
|
-
toast.success("
|
|
195
|
+
toast.success(t("branding.toast.clear_success"));
|
|
195
196
|
onSave === null || onSave === void 0 ? void 0 : onSave(null);
|
|
196
197
|
}
|
|
197
198
|
else {
|
|
198
|
-
toast.error(data.error || "
|
|
199
|
+
toast.error(data.error || t("branding.toast.clear_failed"));
|
|
199
200
|
}
|
|
200
201
|
}
|
|
201
202
|
catch (error) {
|
|
202
|
-
toast.error("
|
|
203
|
+
toast.error(t("branding.toast.clear_failed"));
|
|
203
204
|
}
|
|
204
205
|
finally {
|
|
205
206
|
setSaving(false);
|
|
@@ -219,10 +220,10 @@ export function BrandingEditor({ scopeId, scopeName, isOpen, onClose, onSave, in
|
|
|
219
220
|
const handleFooterLinkChange = (index, field, value) => {
|
|
220
221
|
setPublicLinks((prev) => prev.map((link, i) => (i === index ? Object.assign(Object.assign({}, link), { [field]: value }) : link)));
|
|
221
222
|
};
|
|
222
|
-
return (_jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: _jsxs(DialogContent, { className: "cls_branding_editor_dialog max-w-lg", children: [_jsxs(DialogHeader, { children: [_jsxs(DialogTitle, { className: "flex items-center gap-2", children: [_jsx(Palette, { className: "h-5 w-5" }), "
|
|
223
|
+
return (_jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: _jsxs(DialogContent, { className: "cls_branding_editor_dialog max-w-lg", children: [_jsxs(DialogHeader, { children: [_jsxs(DialogTitle, { className: "flex items-center gap-2", children: [_jsx(Palette, { className: "h-5 w-5" }), t("branding.dialog_title")] }), _jsx(DialogDescription, { children: t("branding.dialog_description", { scopeName }) })] }), loading ? (_jsx("div", { className: "flex items-center justify-center p-8", children: _jsx(Loader2, { className: "h-6 w-6 animate-spin text-slate-400" }) })) : (_jsxs("div", { className: "flex flex-col gap-6 py-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: t("branding.logo_label") }), _jsxs("div", { className: "flex items-start gap-4", children: [_jsx("div", { className: "flex-shrink-0 w-24 h-24 border rounded-lg overflow-hidden bg-muted flex items-center justify-center", children: logoUrl ? (_jsx("img", { src: logoUrl, alt: t("branding.logo_alt"), className: "w-full h-full object-contain" })) : (_jsx(ImageIcon, { className: "h-8 w-8 text-muted-foreground" })) }), _jsxs("div", { className: "flex flex-col gap-2 flex-1", children: [_jsx("input", { type: "file", ref: fileInputRef, onChange: handleFileChange, accept: "image/png,image/jpeg,image/svg+xml,image/webp", className: "hidden" }), _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: handleUploadClick, disabled: uploading, children: uploading ? (_jsxs(_Fragment, { children: [_jsx(Loader2, { className: "h-4 w-4 mr-2 animate-spin" }), t("branding.uploading")] })) : (_jsxs(_Fragment, { children: [_jsx(Upload, { className: "h-4 w-4 mr-2" }), t("branding.upload_logo_button")] })) }), logoUrl && (_jsxs(Button, { type: "button", variant: "ghost", size: "sm", onClick: handleRemoveLogo, className: "text-destructive hover:text-destructive", children: [_jsx(Trash2, { className: "h-4 w-4 mr-2" }), t("branding.remove_button")] })), _jsx("p", { className: "text-xs text-muted-foreground", children: t("branding.logo_hint") })] })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { htmlFor: "primary_color", children: t("branding.primary_color_label") }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Input, { id: "primary_color", type: "text", value: primaryColor, onChange: (e) => setPrimaryColor(e.target.value), placeholder: "#1a73e8", className: "flex-1" }), _jsx("input", { type: "color", value: primaryColor || "#000000", onChange: (e) => setPrimaryColor(e.target.value), className: "w-10 h-10 rounded border cursor-pointer", title: t("branding.pick_color_title") })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { htmlFor: "secondary_color", children: t("branding.secondary_color_label") }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Input, { id: "secondary_color", type: "text", value: secondaryColor, onChange: (e) => setSecondaryColor(e.target.value), placeholder: "#4285f4", className: "flex-1" }), _jsx("input", { type: "color", value: secondaryColor || "#000000", onChange: (e) => setSecondaryColor(e.target.value), className: "w-10 h-10 rounded border cursor-pointer", title: t("branding.pick_color_title") })] })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { htmlFor: "tagline", children: t("branding.tagline_label") }), _jsx(Input, { id: "tagline", type: "text", value: tagline, onChange: (e) => setTagline(e.target.value), placeholder: t("branding.tagline_placeholder"), maxLength: 200 }), _jsx("p", { className: "text-xs text-muted-foreground", children: t("branding.tagline_hint") })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { htmlFor: "app_title", children: t("branding.app_title_label") }), _jsx(Input, { id: "app_title", type: "text", value: appTitle, onChange: (e) => setAppTitle(e.target.value), placeholder: t("branding.app_title_placeholder"), maxLength: 200 }), _jsx("p", { className: "text-xs text-muted-foreground", children: t("branding.app_title_hint") })] }), _jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(Label, { children: t("branding.footer_label") }), _jsxs("div", { className: "flex flex-col gap-2 rounded-lg border p-3", children: [_jsx(Label, { htmlFor: "public_footer_copyright", className: "text-xs text-muted-foreground", children: t("branding.public_footer_copyright_label") }), _jsx(Input, { id: "public_footer_copyright", type: "text", value: publicCopyright, onChange: (e) => setPublicCopyright(e.target.value), placeholder: t("branding.footer_copyright_placeholder") }), _jsxs("div", { className: "flex flex-col gap-2 mt-2", children: [_jsx(Label, { className: "text-xs text-muted-foreground", children: t("branding.public_footer_links_label") }), publicLinks.map((link, index) => (_jsxs("div", { className: "flex gap-2 items-center", children: [_jsx(Input, { type: "text", value: link.label, onChange: (e) => handleFooterLinkChange(index, "label", e.target.value), placeholder: t("branding.link_label_placeholder"), className: "flex-1" }), _jsx(Input, { type: "text", value: link.href, onChange: (e) => handleFooterLinkChange(index, "href", e.target.value), placeholder: t("branding.link_href_placeholder"), className: "flex-1" }), _jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: () => handleRemoveFooterLink(index), className: "text-destructive hover:text-destructive", children: _jsx(Trash2, { className: "h-4 w-4" }) })] }, index))), _jsxs(Button, { type: "button", variant: "outline", size: "sm", onClick: handleAddFooterLink, className: "self-start", children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), t("branding.add_link_button")] })] })] }), _jsxs("div", { className: "flex flex-col gap-2 rounded-lg border p-3", children: [_jsx(Label, { htmlFor: "app_footer_copyright", className: "text-xs text-muted-foreground", children: t("branding.app_footer_copyright_label") }), _jsx(Input, { id: "app_footer_copyright", type: "text", value: appCopyright, onChange: (e) => setAppCopyright(e.target.value), placeholder: t("branding.footer_copyright_placeholder") })] })] }), (logoUrl || primaryColor || tagline) && (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: t("branding.preview_label") }), _jsx("div", { className: "p-4 rounded-lg border", style: {
|
|
223
224
|
backgroundColor: primaryColor
|
|
224
225
|
? `${primaryColor}10`
|
|
225
226
|
: undefined,
|
|
226
227
|
borderColor: primaryColor || undefined,
|
|
227
|
-
}, children: _jsxs("div", { className: "flex items-center gap-3", children: [logoUrl && (_jsx("img", { src: logoUrl, alt: "
|
|
228
|
+
}, children: _jsxs("div", { className: "flex items-center gap-3", children: [logoUrl && (_jsx("img", { src: logoUrl, alt: t("branding.logo_preview_alt"), className: "h-10 w-10 object-contain" })), _jsxs("div", { children: [_jsx("div", { className: "font-semibold", style: { color: primaryColor || undefined }, children: scopeName }), tagline && (_jsx("div", { className: "text-sm", style: { color: secondaryColor || undefined }, children: tagline }))] })] }) })] }))] })), _jsxs(DialogFooter, { className: "flex gap-2 sm:gap-0", children: [_jsxs(Button, { variant: "ghost", size: "sm", onClick: handleClear, disabled: saving || loading, className: "text-destructive hover:text-destructive", children: [_jsx(Trash2, { className: "h-4 w-4 mr-2" }), t("branding.clear_all_button")] }), _jsx("div", { className: "flex-1" }), _jsxs(Button, { variant: "outline", onClick: onClose, disabled: saving, children: [_jsx(CircleX, { className: "h-4 w-4 mr-2" }), t("shared.cancel_button")] }), _jsx(Button, { onClick: handleSave, disabled: saving || loading, children: saving ? (_jsxs(_Fragment, { children: [_jsx(Loader2, { className: "h-4 w-4 mr-2 animate-spin" }), t("branding.saving")] })) : (_jsxs(_Fragment, { children: [_jsx(CircleCheck, { className: "h-4 w-4 mr-2" }), t("shared.save_button")] })) })] })] }) }));
|
|
228
229
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app_user_data_editor.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/user_management/components/app_user_data_editor.tsx"],"names":[],"mappings":"AA6CA,MAAM,MAAM,sBAAsB,GAAG;IACnC,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC5C,kCAAkC;IAClC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACpD,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAgDF,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,WAAW,EACX,MAAM,EACN,OAAO,EACP,QAAgB,GACjB,EAAE,sBAAsB,+
|
|
1
|
+
{"version":3,"file":"app_user_data_editor.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/user_management/components/app_user_data_editor.tsx"],"names":[],"mappings":"AA6CA,MAAM,MAAM,sBAAsB,GAAG;IACnC,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC5C,kCAAkC;IAClC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACpD,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAgDF,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,WAAW,EACX,MAAM,EACN,OAAO,EACP,QAAgB,GACjB,EAAE,sBAAsB,+BAmXxB"}
|
|
@@ -12,7 +12,7 @@ import { Switch } from "../../../ui/switch.js";
|
|
|
12
12
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "../../../ui/alert-dialog.js";
|
|
13
13
|
import { ChevronDown, ChevronRight, Edit, Loader2, Save, Trash2, X } from "lucide-react";
|
|
14
14
|
import { toast } from "sonner";
|
|
15
|
-
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider.js";
|
|
15
|
+
import { useHazoAuthConfig, useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
16
16
|
// section: helpers
|
|
17
17
|
/**
|
|
18
18
|
* Get nested value from object using dot-notation path
|
|
@@ -52,6 +52,7 @@ function setNestedValue(obj, path, value) {
|
|
|
52
52
|
// section: component
|
|
53
53
|
export function AppUserDataEditor({ userId, currentData, onSave, onClear, readOnly = false, }) {
|
|
54
54
|
const { apiBasePath } = useHazoAuthConfig();
|
|
55
|
+
const t = useAuthT();
|
|
55
56
|
const [schemaResponse, setSchemaResponse] = useState(null);
|
|
56
57
|
const [schemaLoading, setSchemaLoading] = useState(true);
|
|
57
58
|
const [isEditing, setIsEditing] = useState(false);
|
|
@@ -108,22 +109,22 @@ export function AppUserDataEditor({ userId, currentData, onSave, onClear, readOn
|
|
|
108
109
|
});
|
|
109
110
|
const data = await response.json();
|
|
110
111
|
if (data.success) {
|
|
111
|
-
toast.success("
|
|
112
|
+
toast.success(t("app_user_data.toast.save_success"));
|
|
112
113
|
setIsEditing(false);
|
|
113
114
|
onSave === null || onSave === void 0 ? void 0 : onSave(editData);
|
|
114
115
|
}
|
|
115
116
|
else {
|
|
116
|
-
toast.error(data.error || "
|
|
117
|
+
toast.error(data.error || t("app_user_data.toast.save_failed"));
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
catch (error) {
|
|
120
|
-
toast.error("
|
|
121
|
+
toast.error(t("app_user_data.toast.save_failed"));
|
|
121
122
|
console.error("Save error:", error);
|
|
122
123
|
}
|
|
123
124
|
finally {
|
|
124
125
|
setSaving(false);
|
|
125
126
|
}
|
|
126
|
-
}, [apiBasePath, userId, editData, onSave]);
|
|
127
|
+
}, [apiBasePath, userId, editData, onSave, t]);
|
|
127
128
|
// Clear app_user_data - uses user_management/users PATCH endpoint with null
|
|
128
129
|
const handleClear = useCallback(async () => {
|
|
129
130
|
setClearing(true);
|
|
@@ -138,22 +139,22 @@ export function AppUserDataEditor({ userId, currentData, onSave, onClear, readOn
|
|
|
138
139
|
});
|
|
139
140
|
const data = await response.json();
|
|
140
141
|
if (data.success) {
|
|
141
|
-
toast.success("
|
|
142
|
+
toast.success(t("app_user_data.toast.clear_success"));
|
|
142
143
|
setShowClearConfirmation(false);
|
|
143
144
|
onClear === null || onClear === void 0 ? void 0 : onClear();
|
|
144
145
|
}
|
|
145
146
|
else {
|
|
146
|
-
toast.error(data.error || "
|
|
147
|
+
toast.error(data.error || t("app_user_data.toast.clear_failed"));
|
|
147
148
|
}
|
|
148
149
|
}
|
|
149
150
|
catch (error) {
|
|
150
|
-
toast.error("
|
|
151
|
+
toast.error(t("app_user_data.toast.clear_failed"));
|
|
151
152
|
console.error("Clear error:", error);
|
|
152
153
|
}
|
|
153
154
|
finally {
|
|
154
155
|
setClearing(false);
|
|
155
156
|
}
|
|
156
|
-
}, [apiBasePath, userId, onClear]);
|
|
157
|
+
}, [apiBasePath, userId, onClear, t]);
|
|
157
158
|
// Update field value
|
|
158
159
|
const updateField = useCallback((path, value) => {
|
|
159
160
|
setEditData((prev) => setNestedValue(prev, path, value));
|
|
@@ -202,7 +203,7 @@ export function AppUserDataEditor({ userId, currentData, onSave, onClear, readOn
|
|
|
202
203
|
displayValue = "-";
|
|
203
204
|
}
|
|
204
205
|
else if (typeof currentValue === "boolean") {
|
|
205
|
-
displayValue = currentValue ? "
|
|
206
|
+
displayValue = currentValue ? t("app_user_data.boolean_yes") : t("app_user_data.boolean_no");
|
|
206
207
|
}
|
|
207
208
|
else {
|
|
208
209
|
displayValue = String(currentValue);
|
|
@@ -230,8 +231,8 @@ export function AppUserDataEditor({ userId, currentData, onSave, onClear, readOn
|
|
|
230
231
|
}
|
|
231
232
|
// Schema not enabled - show raw data
|
|
232
233
|
if (!(schemaResponse === null || schemaResponse === void 0 ? void 0 : schemaResponse.enabled) || !(schemaResponse === null || schemaResponse === void 0 ? void 0 : schemaResponse.schema)) {
|
|
233
|
-
return (_jsx("div", { className: "text-sm", children: currentData && Object.keys(currentData).length > 0 ? (_jsx("pre", { className: "border rounded-lg p-2 bg-slate-50 overflow-x-auto text-xs", children: JSON.stringify(currentData, null, 2) })) : (_jsx("span", { className: "text-muted-foreground", children: "
|
|
234
|
+
return (_jsx("div", { className: "text-sm", children: currentData && Object.keys(currentData).length > 0 ? (_jsx("pre", { className: "border rounded-lg p-2 bg-slate-50 overflow-x-auto text-xs", children: JSON.stringify(currentData, null, 2) })) : (_jsx("span", { className: "text-muted-foreground", children: t("app_user_data.empty_state") })) }));
|
|
234
235
|
}
|
|
235
236
|
// Render schema-based editor
|
|
236
|
-
return (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("h3", { className: "text-sm font-semibold uppercase tracking-wide text-muted-foreground", children: "
|
|
237
|
+
return (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("h3", { className: "text-sm font-semibold uppercase tracking-wide text-muted-foreground", children: t("app_user_data.heading") }), !readOnly && !isEditing && (_jsxs("div", { className: "flex gap-2", children: [_jsxs(Button, { variant: "outline", size: "sm", onClick: handleEdit, className: "h-8", children: [_jsx(Edit, { className: "h-3.5 w-3.5 mr-1.5" }), t("app_user_data.edit_button")] }), currentData && Object.keys(currentData).length > 0 && (_jsxs(Button, { variant: "outline", size: "sm", onClick: () => setShowClearConfirmation(true), className: "h-8 text-destructive hover:text-destructive hover:bg-destructive/10", children: [_jsx(Trash2, { className: "h-3.5 w-3.5 mr-1.5" }), t("app_user_data.clear_button")] }))] }))] }), _jsx("div", { className: "flex flex-col gap-3", children: Object.entries(schemaResponse.schema.properties).map(([sectionKey, sectionSchema]) => renderSection(sectionKey, sectionSchema)) }), isEditing && (_jsxs("div", { className: "flex justify-end gap-2 pt-3 border-t", children: [_jsxs(Button, { variant: "outline", size: "sm", onClick: handleCancel, disabled: saving, className: "h-9", children: [_jsx(X, { className: "h-4 w-4 mr-1.5" }), t("shared.cancel_button")] }), _jsxs(Button, { size: "sm", onClick: handleSave, disabled: saving, className: "h-9", children: [saving ? (_jsx(Loader2, { className: "h-4 w-4 mr-1.5 animate-spin" })) : (_jsx(Save, { className: "h-4 w-4 mr-1.5" })), t("shared.save_button")] })] })), _jsx(AlertDialog, { open: showClearConfirmation, onOpenChange: setShowClearConfirmation, children: _jsxs(AlertDialogContent, { children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: t("app_user_data.clear_dialog.title") }), _jsx(AlertDialogDescription, { children: t("app_user_data.clear_dialog.description") })] }), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { disabled: clearing, children: t("shared.cancel_button") }), _jsx(AlertDialogAction, { onClick: handleClear, disabled: clearing, className: "bg-destructive text-destructive-foreground hover:bg-destructive/90", children: clearing ? (_jsxs(_Fragment, { children: [_jsx(Loader2, { className: "h-4 w-4 mr-1.5 animate-spin" }), t("app_user_data.clear_dialog.confirming")] })) : (t("app_user_data.clear_dialog.confirm")) })] })] }) })] }));
|
|
237
238
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user_signup_stats_cards.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/user_management/components/user_signup_stats_cards.tsx"],"names":[],"mappings":"AAMA,OAAO,KAA4B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"user_signup_stats_cards.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/user_management/components/user_signup_stats_cards.tsx"],"names":[],"mappings":"AAMA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAQjD,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,aAAa,CAAC;QAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IACrD,8DAA8D;IAC9D,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAkOD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,yBAAyB,qBAaxF"}
|
|
@@ -6,18 +6,21 @@
|
|
|
6
6
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { useMemo, useState } from "react";
|
|
8
8
|
import { computeUserSignupStats, } from "../../../../lib/user_signup_stats.js";
|
|
9
|
+
import { useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
9
10
|
function DeltaBadge({ pct }) {
|
|
11
|
+
const t = useAuthT();
|
|
10
12
|
if (pct === null) {
|
|
11
13
|
return _jsx("span", { className: "text-xs text-muted-foreground", children: "\u2014" });
|
|
12
14
|
}
|
|
13
15
|
const up = pct >= 0;
|
|
14
16
|
const cls = up ? "text-emerald-600" : "text-red-600";
|
|
15
17
|
const arrow = up ? "▲" : "▼";
|
|
16
|
-
return (_jsxs("span", { className: `text-xs font-medium ${cls}`, title: "
|
|
18
|
+
return (_jsxs("span", { className: `text-xs font-medium ${cls}`, title: t("user_management.signup_stats.vs_previous"), children: [arrow, " ", up ? "+" : "", pct, "%"] }));
|
|
17
19
|
}
|
|
18
20
|
const STAT_CARD_HEIGHT_PX = 168;
|
|
19
21
|
function StatCard({ w }) {
|
|
20
|
-
|
|
22
|
+
const t = useAuthT();
|
|
23
|
+
return (_jsxs("div", { className: "cls_user_signup_stat_card flex min-w-0 flex-col justify-between rounded-lg border bg-card p-4", style: { height: STAT_CARD_HEIGHT_PX }, children: [_jsx("div", { className: "truncate text-xs text-muted-foreground", children: w.label }), _jsxs("div", { className: "flex items-baseline justify-between gap-1", children: [_jsx("span", { className: "text-3xl font-bold tabular-nums", children: w.count.toLocaleString() }), w.key !== "all" && _jsx(DeltaBadge, { pct: w.pctChange })] }), w.key !== "all" && w.prevCount !== null && (_jsx("div", { className: "truncate text-xs text-muted-foreground", children: t("user_management.signup_stats.prev_count", { count: w.prevCount.toLocaleString() }) })), w.key === "all" && (_jsx("div", { className: "truncate text-xs text-muted-foreground", children: t("user_management.signup_stats.total_users") }))] }));
|
|
21
24
|
}
|
|
22
25
|
/** Round a value up to a "nice" axis maximum (1/2/5 * 10^n steps). */
|
|
23
26
|
function niceMax(n) {
|
|
@@ -38,6 +41,7 @@ function niceMax(n) {
|
|
|
38
41
|
return niceFrac * base;
|
|
39
42
|
}
|
|
40
43
|
function YtdMiniChart({ data }) {
|
|
44
|
+
const t = useAuthT();
|
|
41
45
|
const [hoverIndex, setHoverIndex] = useState(null);
|
|
42
46
|
const total = data.reduce((n, d) => n + d.count, 0);
|
|
43
47
|
const rawMax = Math.max(1, ...data.map((d) => d.count));
|
|
@@ -60,9 +64,9 @@ function YtdMiniChart({ data }) {
|
|
|
60
64
|
const bw = Math.max(1, colW - gap);
|
|
61
65
|
const yFor = (value) => marginTop + plotH - (value / max) * plotH;
|
|
62
66
|
const hovered = hoverIndex !== null ? data[hoverIndex] : null;
|
|
63
|
-
return (_jsxs("div", { className: "cls_user_signup_ytd_chart col-span-6 flex min-w-0 flex-col rounded-lg border bg-card p-3", style: { height: STAT_CARD_HEIGHT_PX }, children: [_jsxs("div", { className: "flex shrink-0 items-baseline justify-between", children: [_jsx("div", { className: "truncate text-[11px] text-muted-foreground", children: "
|
|
64
|
-
.map((d) => `${d.label} ${d.count}`)
|
|
65
|
-
|
|
67
|
+
return (_jsxs("div", { className: "cls_user_signup_ytd_chart col-span-6 flex min-w-0 flex-col rounded-lg border bg-card p-3", style: { height: STAT_CARD_HEIGHT_PX }, children: [_jsxs("div", { className: "flex shrink-0 items-baseline justify-between", children: [_jsx("div", { className: "truncate text-[11px] text-muted-foreground", children: t("user_management.signup_stats.ytd_title") }), _jsx("div", { className: "text-sm font-semibold tabular-nums", children: total.toLocaleString() })] }), _jsxs("div", { className: "relative mt-2 min-h-0 flex-1", children: [_jsxs("svg", { role: "img", "aria-label": t("user_management.signup_stats.ytd_aria", {
|
|
68
|
+
list: data.map((d) => `${d.label} ${d.count}`).join(", "),
|
|
69
|
+
}), viewBox: `0 0 ${W} ${H}`, preserveAspectRatio: "none", className: "h-full w-full", children: [[0, mid, max].map((tick) => {
|
|
66
70
|
const y = yFor(tick);
|
|
67
71
|
return (_jsxs("g", { children: [_jsx("line", { x1: marginLeft, x2: W - marginRight, y1: y, y2: y, stroke: "currentColor", strokeOpacity: 0.1 }), _jsx("text", { x: marginLeft - 6, y: y, dy: 3, textAnchor: "end", fontSize: 9, className: "fill-muted-foreground", children: tick.toLocaleString() })] }, tick));
|
|
68
72
|
}), _jsx("line", { x1: marginLeft, x2: W - marginRight, y1: marginTop + plotH, y2: marginTop + plotH, stroke: "currentColor", strokeOpacity: 0.2 }), data.map((d, i) => {
|
|
@@ -72,11 +76,11 @@ function YtdMiniChart({ data }) {
|
|
|
72
76
|
const barY = marginTop + plotH - barH;
|
|
73
77
|
const centerX = colX + colW / 2;
|
|
74
78
|
const isDimmed = hoverIndex !== null && hoverIndex !== i;
|
|
75
|
-
return (_jsxs("g", { onMouseEnter: () => setHoverIndex(i), onMouseLeave: () => setHoverIndex(null), children: [_jsx("rect", { x: colX, y: marginTop, width: colW, height: plotH, fill: "transparent" }), _jsx("rect", { x: barX, y: barY, width: bw, height: Math.max(0, barH), rx: 2, className: "fill-primary", fillOpacity: isDimmed ? 0.45 : 1, children: _jsx("title", { children: `${d.label}: ${d.count}` }) }), _jsx("text", { x: centerX, y: barY - 4, textAnchor: "middle", fontSize: 10, fontWeight: 600, className: "fill-foreground", children: d.count }), _jsx("text", { x: centerX, y: marginTop + plotH + 14, textAnchor: "middle", fontSize: 9, className: "fill-muted-foreground", children: d.label })] }, d.label));
|
|
79
|
+
return (_jsxs("g", { onMouseEnter: () => setHoverIndex(i), onMouseLeave: () => setHoverIndex(null), children: [_jsx("rect", { x: colX, y: marginTop, width: colW, height: plotH, fill: "transparent" }), _jsx("rect", { x: barX, y: barY, width: bw, height: Math.max(0, barH), rx: 2, className: "fill-primary", fillOpacity: isDimmed ? 0.45 : 1, children: _jsx("title", { children: `${d.label}: ${d.count} ${t("user_management.signup_stats.tooltip_suffix")}` }) }), _jsx("text", { x: centerX, y: barY - 4, textAnchor: "middle", fontSize: 10, fontWeight: 600, className: "fill-foreground", children: d.count }), _jsx("text", { x: centerX, y: marginTop + plotH + 14, textAnchor: "middle", fontSize: 9, className: "fill-muted-foreground", children: d.label })] }, d.label));
|
|
76
80
|
})] }), hovered && hoverIndex !== null && (_jsxs("div", { className: "pointer-events-none absolute z-10 -translate-x-1/2 -translate-y-full rounded-md border bg-popover px-2 py-1 text-[10px] font-medium text-popover-foreground shadow-sm", style: {
|
|
77
81
|
left: `${Math.min(92, Math.max(8, ((marginLeft + hoverIndex * (plotW / n) + plotW / n / 2) / W) * 100))}%`,
|
|
78
82
|
top: `${((marginTop + plotH - (hovered.count / max) * plotH) / H) * 100}%`,
|
|
79
|
-
}, children: [hovered.label, ": ", hovered.count, "
|
|
83
|
+
}, children: [hovered.label, ": ", hovered.count, " ", t("user_management.signup_stats.tooltip_suffix")] }))] })] }));
|
|
80
84
|
}
|
|
81
85
|
/**
|
|
82
86
|
* Total + rolling-window signup cards (All time, 7d, 30d, 3mo, 6mo, YTD) each
|
|
@@ -7,7 +7,7 @@ import { Label } from "../ui/label.js";
|
|
|
7
7
|
import { useAuthT } from "../../contexts/hazo_auth_provider.js";
|
|
8
8
|
export function OTPRequestForm({ on_sent, api_base = "/api/hazo_auth", email_label, submit_label, pending_label, className, }) {
|
|
9
9
|
const t = useAuthT();
|
|
10
|
-
const resolvedEmailLabel = email_label !== null && email_label !== void 0 ? email_label : t("
|
|
10
|
+
const resolvedEmailLabel = email_label !== null && email_label !== void 0 ? email_label : t("shared.field.email.label");
|
|
11
11
|
const resolvedSubmitLabel = submit_label !== null && submit_label !== void 0 ? submit_label : t("otp.request.submit_label");
|
|
12
12
|
const resolvedPendingLabel = pending_label !== null && pending_label !== void 0 ? pending_label : t("otp.request.pending_label");
|
|
13
13
|
const [email, set_email] = React.useState("");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie_consent_banner.d.ts","sourceRoot":"","sources":["../../src/consent/cookie_consent_banner.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"cookie_consent_banner.d.ts","sourceRoot":"","sources":["../../src/consent/cookie_consent_banner.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAMpD,UAAU,wBAAwB;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACzC,wBAAwB;IACxB,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;CAC7B;AAED,wBAAgB,mBAAmB,CAAC,EAClC,SAAS,EACT,cAAc,EACd,QAAQ,EACR,QAAmB,GACpB,EAAE,wBAAwB,+BA4E1B"}
|
|
@@ -5,8 +5,10 @@ import { useEffect, useRef } from "react";
|
|
|
5
5
|
import { useConsent } from "./use_consent.js";
|
|
6
6
|
import { ConsentManageModal } from "./manage_modal.js";
|
|
7
7
|
import { to_gtm_signals, gtm_default_payload } from "./gtm_mapping.js";
|
|
8
|
+
import { useAuthT } from "../contexts/hazo_auth_provider.js";
|
|
8
9
|
export function CookieConsentBanner({ enableGTM, gtmContainerId, onChange, position = "bottom", }) {
|
|
9
10
|
const { consent, set_consent, open_manager } = useConsent();
|
|
11
|
+
const t = useAuthT();
|
|
10
12
|
const gtm_default_pushed = useRef(false);
|
|
11
13
|
// Push consent_default to GTM on first mount (before user has consented)
|
|
12
14
|
useEffect(() => {
|
|
@@ -36,5 +38,5 @@ export function CookieConsentBanner({ enableGTM, gtmContainerId, onChange, posit
|
|
|
36
38
|
return _jsx(ConsentManageModal, {});
|
|
37
39
|
}
|
|
38
40
|
const positionClass = position === "top" ? "top-0" : "bottom-0";
|
|
39
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: `fixed ${positionClass} left-0 right-0 z-40 bg-primary text-primary-foreground p-4 flex flex-wrap items-center gap-3 justify-between`, children: [_jsx("p", { className: "text-sm flex-1 min-w-[200px]", children: "
|
|
41
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: `fixed ${positionClass} left-0 right-0 z-40 bg-primary text-primary-foreground p-4 flex flex-wrap items-center gap-3 justify-between`, children: [_jsx("p", { className: "text-sm flex-1 min-w-[200px]", children: t("consent.banner_body") }), _jsxs("div", { className: "flex gap-2 flex-wrap", children: [_jsx("button", { onClick: () => set_consent({ functional: false, analytics: false, marketing: false }), className: "px-3 py-1.5 text-xs bg-primary-foreground/20 hover:bg-primary-foreground/30 rounded text-primary-foreground", children: t("consent.decline_all") }), _jsx("button", { onClick: () => open_manager(), className: "px-3 py-1.5 text-xs bg-primary-foreground/20 hover:bg-primary-foreground/30 rounded text-primary-foreground", children: t("consent.manage") }), _jsx("button", { onClick: () => set_consent({ functional: true, analytics: true, marketing: true }), className: "px-3 py-1.5 text-xs bg-primary-foreground rounded text-primary font-medium", children: t("consent.accept_all") })] })] }), _jsx(ConsentManageModal, {})] }));
|
|
40
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manage_modal.d.ts","sourceRoot":"","sources":["../../src/consent/manage_modal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manage_modal.d.ts","sourceRoot":"","sources":["../../src/consent/manage_modal.tsx"],"names":[],"mappings":"AAQA,wBAAgB,kBAAkB,gCA2GjC"}
|
|
@@ -4,7 +4,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
import { useEffect, useState } from "react";
|
|
5
5
|
import * as Dialog from "@radix-ui/react-dialog";
|
|
6
6
|
import { useConsent } from "./use_consent.js";
|
|
7
|
+
import { useAuthT } from "../contexts/hazo_auth_provider.js";
|
|
7
8
|
export function ConsentManageModal() {
|
|
9
|
+
const t = useAuthT();
|
|
8
10
|
const { consent, set_consent } = useConsent();
|
|
9
11
|
const [open, setOpen] = useState(false);
|
|
10
12
|
const [local, setLocal] = useState({
|
|
@@ -29,5 +31,5 @@ export function ConsentManageModal() {
|
|
|
29
31
|
set_consent(Object.assign(Object.assign({}, local), { necessary: true, version: 1 }));
|
|
30
32
|
setOpen(false);
|
|
31
33
|
};
|
|
32
|
-
return (_jsx(Dialog.Root, { open: open, onOpenChange: setOpen, children: _jsxs(Dialog.Portal, { children: [_jsx(Dialog.Overlay, { className: "fixed inset-0 bg-black/50 z-50" }), _jsxs(Dialog.Content, { className: "fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-background rounded-lg p-6 z-50 w-full max-w-md shadow-lg", children: [_jsx(Dialog.Title, { className: "text-lg font-semibold mb-4", children: "
|
|
34
|
+
return (_jsx(Dialog.Root, { open: open, onOpenChange: setOpen, children: _jsxs(Dialog.Portal, { children: [_jsx(Dialog.Overlay, { className: "fixed inset-0 bg-black/50 z-50" }), _jsxs(Dialog.Content, { className: "fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-background rounded-lg p-6 z-50 w-full max-w-md shadow-lg", children: [_jsx(Dialog.Title, { className: "text-lg font-semibold mb-4", children: t("consent.preferences_title") }), _jsxs("div", { className: "flex items-center justify-between py-3 border-b", children: [_jsxs("div", { children: [_jsx("p", { className: "font-medium", children: t("consent.category_necessary") }), _jsx("p", { className: "text-sm text-muted-foreground", children: t("consent.category_necessary_desc") })] }), _jsx("input", { type: "checkbox", checked: true, disabled: true, className: "h-4 w-4" })] }), _jsxs("div", { className: "flex items-center justify-between py-3 border-b", children: [_jsxs("div", { children: [_jsx("p", { className: "font-medium", children: t("consent.category_functional") }), _jsx("p", { className: "text-sm text-muted-foreground", children: t("consent.category_functional_desc") })] }), _jsx("input", { type: "checkbox", checked: local.functional, onChange: (e) => setLocal((p) => (Object.assign(Object.assign({}, p), { functional: e.target.checked }))), className: "h-4 w-4" })] }), _jsxs("div", { className: "flex items-center justify-between py-3 border-b", children: [_jsxs("div", { children: [_jsx("p", { className: "font-medium", children: t("consent.category_analytics") }), _jsx("p", { className: "text-sm text-muted-foreground", children: t("consent.category_analytics_desc") })] }), _jsx("input", { type: "checkbox", checked: local.analytics, onChange: (e) => setLocal((p) => (Object.assign(Object.assign({}, p), { analytics: e.target.checked }))), className: "h-4 w-4" })] }), _jsxs("div", { className: "flex items-center justify-between py-3", children: [_jsxs("div", { children: [_jsx("p", { className: "font-medium", children: t("consent.category_marketing") }), _jsx("p", { className: "text-sm text-muted-foreground", children: t("consent.category_marketing_desc") })] }), _jsx("input", { type: "checkbox", checked: local.marketing, onChange: (e) => setLocal((p) => (Object.assign(Object.assign({}, p), { marketing: e.target.checked }))), className: "h-4 w-4" })] }), _jsxs("div", { className: "mt-6 flex gap-3 justify-end", children: [_jsx("button", { className: "px-4 py-2 text-sm border rounded-md hover:bg-muted", onClick: () => setOpen(false), children: t("shared.cancel_button") }), _jsx("button", { className: "px-4 py-2 text-sm bg-primary text-primary-foreground rounded-md hover:opacity-90", onClick: save, children: t("consent.save_preferences") })] })] })] }) }));
|
|
33
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password_change_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/password_change_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"password_change_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/password_change_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AASvD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,oBAAoB,CAAC,CA4F/B"}
|
|
@@ -3,6 +3,7 @@ import argon2 from "argon2";
|
|
|
3
3
|
import { get_password_requirements_config } from "../password_requirements_config.server.js";
|
|
4
4
|
import { send_template_email } from "./email_service.js";
|
|
5
5
|
import { create_app_logger } from "../app_logger.js";
|
|
6
|
+
import { validate_password } from "../utils/password_validator.js";
|
|
6
7
|
// section: helpers
|
|
7
8
|
/**
|
|
8
9
|
* Changes a user's password
|
|
@@ -50,34 +51,11 @@ export async function change_password(adapter, user_id, data) {
|
|
|
50
51
|
// Get password requirements from config
|
|
51
52
|
const password_requirements = get_password_requirements_config();
|
|
52
53
|
// Validate new password
|
|
53
|
-
|
|
54
|
+
const password_validation = validate_password(new_password, password_requirements);
|
|
55
|
+
if (!password_validation.valid) {
|
|
54
56
|
return {
|
|
55
57
|
success: false,
|
|
56
|
-
error:
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
if (password_requirements.require_uppercase && !/[A-Z]/.test(new_password)) {
|
|
60
|
-
return {
|
|
61
|
-
success: false,
|
|
62
|
-
error: "Password must contain at least one uppercase letter",
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
if (password_requirements.require_lowercase && !/[a-z]/.test(new_password)) {
|
|
66
|
-
return {
|
|
67
|
-
success: false,
|
|
68
|
-
error: "Password must contain at least one lowercase letter",
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
if (password_requirements.require_number && !/[0-9]/.test(new_password)) {
|
|
72
|
-
return {
|
|
73
|
-
success: false,
|
|
74
|
-
error: "Password must contain at least one number",
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
if (password_requirements.require_special && !/[^A-Za-z0-9]/.test(new_password)) {
|
|
78
|
-
return {
|
|
79
|
-
success: false,
|
|
80
|
-
error: "Password must contain at least one special character",
|
|
58
|
+
error: password_validation.errors[0],
|
|
81
59
|
};
|
|
82
60
|
}
|
|
83
61
|
// Hash the new password
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password_validator.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/password_validator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"password_validator.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/password_validator.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,0BAA0B,GAAG;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAGF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,0BAA0B,GACvC,wBAAwB,CA0C1B"}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
// file_description: server-side password validation utility
|
|
2
|
+
//
|
|
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
|
+
// section: constants
|
|
11
|
+
const messages = en;
|
|
1
12
|
// section: helpers
|
|
2
13
|
/**
|
|
3
14
|
* Validates a password against specified requirements (server-side version)
|
|
@@ -10,24 +21,24 @@ export function validate_password(password, requirements) {
|
|
|
10
21
|
if (!password || password.trim().length === 0) {
|
|
11
22
|
return {
|
|
12
23
|
valid: false,
|
|
13
|
-
errors: ["
|
|
24
|
+
errors: [messages["validation.password_required"]],
|
|
14
25
|
};
|
|
15
26
|
}
|
|
16
27
|
if (password.length < requirements.minimum_length) {
|
|
17
|
-
errors.push(
|
|
28
|
+
errors.push(messages["validation.password_too_short"].replace("{{count}}", String(requirements.minimum_length)));
|
|
18
29
|
}
|
|
19
30
|
if (requirements.require_uppercase && !/[A-Z]/.test(password)) {
|
|
20
|
-
errors.push("
|
|
31
|
+
errors.push(messages["validation.password_missing_uppercase"]);
|
|
21
32
|
}
|
|
22
33
|
if (requirements.require_lowercase && !/[a-z]/.test(password)) {
|
|
23
|
-
errors.push("
|
|
34
|
+
errors.push(messages["validation.password_missing_lowercase"]);
|
|
24
35
|
}
|
|
25
36
|
if (requirements.require_number && !/\d/.test(password)) {
|
|
26
|
-
errors.push("
|
|
37
|
+
errors.push(messages["validation.password_missing_number"]);
|
|
27
38
|
}
|
|
28
39
|
if (requirements.require_special &&
|
|
29
40
|
!/[!@#$%^&*(),.?":{}|<>\-_+=\[\];'/\\]/.test(password)) {
|
|
30
|
-
errors.push("
|
|
41
|
+
errors.push(messages["validation.password_missing_special"]);
|
|
31
42
|
}
|
|
32
43
|
return {
|
|
33
44
|
valid: errors.length === 0,
|