hazo_auth 10.15.1 → 10.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli-src/lib/auth/auth_types.ts +3 -0
- package/cli-src/lib/auth/hazo_get_auth.server.ts +1 -0
- package/cli-src/lib/services/oauth_service.ts +17 -2
- package/cli-src/lib/services/user_update_service.ts +9 -0
- package/cli-src/lib/user_signup_stats.ts +118 -0
- package/config/hazo_auth_config.example.ini +22 -0
- package/dist/components/layouts/my_settings/components/language_picker_section.d.ts +23 -0
- package/dist/components/layouts/my_settings/components/language_picker_section.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/language_picker_section.js +40 -0
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts +2 -0
- 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 +31 -0
- package/dist/components/layouts/my_settings/index.d.ts +9 -1
- package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/index.js +3 -2
- package/dist/components/layouts/shared/hooks/use_auth_status.d.ts +1 -0
- package/dist/components/layouts/shared/hooks/use_auth_status.d.ts.map +1 -1
- package/dist/components/layouts/shared/hooks/use_auth_status.js +3 -2
- package/dist/components/layouts/user_management/components/user_signup_stats_cards.d.ts +16 -0
- package/dist/components/layouts/user_management/components/user_signup_stats_cards.d.ts.map +1 -0
- package/dist/components/layouts/user_management/components/user_signup_stats_cards.js +47 -0
- package/dist/components/layouts/user_management/index.d.ts.map +1 -1
- package/dist/components/layouts/user_management/index.js +26 -25
- package/dist/components/ui/sheet.d.ts +1 -1
- package/dist/lib/auth/auth_types.d.ts +1 -0
- package/dist/lib/auth/auth_types.d.ts.map +1 -1
- package/dist/lib/auth/hazo_get_auth.server.d.ts.map +1 -1
- package/dist/lib/auth/hazo_get_auth.server.js +1 -0
- package/dist/lib/services/oauth_service.d.ts.map +1 -1
- package/dist/lib/services/oauth_service.js +13 -6
- package/dist/lib/services/user_update_service.d.ts +1 -0
- package/dist/lib/services/user_update_service.d.ts.map +1 -1
- package/dist/lib/services/user_update_service.js +4 -0
- package/dist/lib/user_signup_stats.d.ts +37 -0
- package/dist/lib/user_signup_stats.d.ts.map +1 -0
- package/dist/lib/user_signup_stats.js +79 -0
- package/dist/server/routes/library_photos.d.ts +2 -2
- package/dist/server/routes/me.d.ts.map +1 -1
- package/dist/server/routes/me.js +3 -1
- package/dist/server/routes/update_user.d.ts.map +1 -1
- package/dist/server/routes/update_user.js +33 -3
- package/legal/privacy.md +63 -0
- package/legal/tos.md +65 -0
- package/package.json +18 -17
|
@@ -9,6 +9,7 @@ import { use_hazo_auth } from "../shared/hooks/use_hazo_auth.js";
|
|
|
9
9
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "../../ui/table.js";
|
|
10
10
|
import { Button } from "../../ui/button.js";
|
|
11
11
|
import { Avatar, AvatarImage, AvatarFallback } from "../../ui/avatar.js";
|
|
12
|
+
import { UserSignupStatsCards } from "./components/user_signup_stats_cards.js";
|
|
12
13
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "../../ui/alert-dialog.js";
|
|
13
14
|
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "../../ui/dialog.js";
|
|
14
15
|
import { Input } from "../../ui/input.js";
|
|
@@ -565,31 +566,31 @@ export function UserManagementLayout({ className, hrbacEnabled = false, userType
|
|
|
565
566
|
};
|
|
566
567
|
return (_jsxs("div", { className: `cls_user_management_layout flex flex-col gap-4 w-full ${className || ""}`, children: [authResult.loading ? (_jsx("div", { className: "cls_user_management_permissions_loading flex items-center justify-center p-8", children: _jsx(Loader2, { className: "h-6 w-6 animate-spin text-slate-400" }) })) : !hasAnyPermission ? (_jsxs("div", { className: "cls_user_management_no_permissions flex flex-col items-center justify-center p-8 gap-4", children: [_jsx("p", { className: "text-lg font-semibold text-slate-700", children: "Access Denied" }), _jsx("p", { className: "text-sm text-muted-foreground text-center", children: "You don't have permission to access User Management. Please contact your administrator." }), process.env.NODE_ENV === "development" && (_jsxs("div", { className: "mt-4 p-4 bg-yellow-50 border border-yellow-200 rounded-md text-xs text-left w-full max-w-lg", children: [_jsx("p", { className: "font-semibold text-yellow-800 mb-2", children: "Dev Debug Info" }), _jsxs("p", { className: "text-yellow-700", children: [_jsx("span", { className: "font-medium", children: "Your permissions:" }), " ", authResult.authenticated && authResult.permissions.length > 0
|
|
567
568
|
? authResult.permissions.join(", ")
|
|
568
|
-
: "(none)"] }), _jsxs("p", { className: "text-yellow-700 mt-1", children: [_jsx("span", { className: "font-medium", children: "Required (any of):" }), " ", "admin_user_management, admin_role_management, admin_permission_management, admin_scope_hierarchy_management, admin_user_scope_assignment, admin_system"] })] }))] })) : (_jsxs(Tabs, { defaultValue: active_tab, onValueChange: set_active_tab, className: "cls_user_management_tabs w-full", children: [_jsxs(TabsList, { className: "cls_user_management_tabs_list flex w-full flex-wrap", children: [showUsersTab && (_jsx(TabsTrigger, { value: "users", className: "cls_user_management_tabs_trigger flex-1", children: "Manage Users" })), showRolesTab && (_jsx(TabsTrigger, { value: "roles", className: "cls_user_management_tabs_trigger flex-1", children: "Roles" })), showPermissionsTab && (_jsx(TabsTrigger, { value: "permissions", className: "cls_user_management_tabs_trigger flex-1", children: "Permissions" })), showScopeHierarchyTab && (_jsx(TabsTrigger, { value: "scope_hierarchy", className: "cls_user_management_tabs_trigger flex-1", children: "Scope Hierarchy" })), showUserScopesTab && (_jsx(TabsTrigger, { value: "user_scopes", className: "cls_user_management_tabs_trigger flex-1", children: "User Scopes" })), hasSystemPermission && (_jsx(TabsTrigger, { value: "legal_docs", className: "cls_user_management_tabs_trigger flex-1", children: "Legal Docs" }))] }), showUsersTab && (
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
569
|
+
: "(none)"] }), _jsxs("p", { className: "text-yellow-700 mt-1", children: [_jsx("span", { className: "font-medium", children: "Required (any of):" }), " ", "admin_user_management, admin_role_management, admin_permission_management, admin_scope_hierarchy_management, admin_user_scope_assignment, admin_system"] })] }))] })) : (_jsxs(Tabs, { defaultValue: active_tab, onValueChange: set_active_tab, className: "cls_user_management_tabs w-full", children: [_jsxs(TabsList, { className: "cls_user_management_tabs_list flex w-full flex-wrap", children: [showUsersTab && (_jsx(TabsTrigger, { value: "users", className: "cls_user_management_tabs_trigger flex-1", children: "Manage Users" })), showRolesTab && (_jsx(TabsTrigger, { value: "roles", className: "cls_user_management_tabs_trigger flex-1", children: "Roles" })), showPermissionsTab && (_jsx(TabsTrigger, { value: "permissions", className: "cls_user_management_tabs_trigger flex-1", children: "Permissions" })), showScopeHierarchyTab && (_jsx(TabsTrigger, { value: "scope_hierarchy", className: "cls_user_management_tabs_trigger flex-1", children: "Scope Hierarchy" })), showUserScopesTab && (_jsx(TabsTrigger, { value: "user_scopes", className: "cls_user_management_tabs_trigger flex-1", children: "User Scopes" })), hasSystemPermission && (_jsx(TabsTrigger, { value: "legal_docs", className: "cls_user_management_tabs_trigger flex-1", children: "Legal Docs" }))] }), showUsersTab && (_jsxs(TabsContent, { value: "users", className: "cls_user_management_tab_users w-full", children: [!usersLoading && users.length > 0 && (_jsx(UserSignupStatsCards, { users: users })), usersLoading ? (_jsx("div", { className: "cls_user_management_users_loading flex items-center justify-center p-8", children: _jsx(Loader2, { className: "h-6 w-6 animate-spin text-slate-400" }) })) : (_jsx("div", { className: "cls_user_management_users_table_container border rounded-lg overflow-auto w-full", children: _jsxs(Table, { className: "cls_user_management_users_table w-full", children: [_jsx(TableHeader, { className: "cls_user_management_users_table_header", children: _jsxs(TableRow, { className: "cls_user_management_users_table_header_row", children: [_jsx(TableHead, { className: "cls_user_management_users_table_header_profile_pic w-16", children: "Photo" }), _jsx(TableHead, { className: "cls_user_management_users_table_header_id", children: "ID" }), _jsx(TableHead, { className: "cls_user_management_users_table_header_name", children: "Name" }), _jsx(TableHead, { className: "cls_user_management_users_table_header_email", children: "Email" }), _jsx(TableHead, { className: "cls_user_management_users_table_header_email_verified", children: "Email Verified" }), _jsx(TableHead, { className: "cls_user_management_users_table_header_is_active", children: "Active" }), _jsx(TableHead, { className: "cls_user_management_users_table_header_last_logon", children: "Last Logon" }), _jsx(TableHead, { className: "cls_user_management_users_table_header_created_at", children: "Created At" }), userTypesEnabled && (_jsx(TableHead, { className: "cls_user_management_users_table_header_user_type", children: "User Type" })), _jsx(TableHead, { className: "cls_user_management_users_table_header_actions text-right", children: "Actions" })] }) }), _jsx(TableBody, { className: "cls_user_management_users_table_body", children: users.length === 0 ? (_jsx(TableRow, { className: "cls_user_management_users_table_row_empty", children: _jsx(TableCell, { colSpan: userTypesEnabled ? 10 : 9, className: "text-center text-muted-foreground py-8", children: "No users found." }) })) : (users.map((user) => (_jsxs(TableRow, { className: "cls_user_management_users_table_row cursor-pointer hover:bg-muted/50", onClick: () => {
|
|
570
|
+
setSelectedUser(user);
|
|
571
|
+
setUserDetailDialogOpen(true);
|
|
572
|
+
}, children: [_jsx(TableCell, { className: "cls_user_management_users_table_cell_profile_pic", children: _jsxs(Avatar, { className: "cls_user_management_users_table_avatar h-8 w-8", children: [_jsx(AvatarImage, { src: user.profile_picture_url || undefined, alt: user.name ? `Profile picture of ${user.name}` : "Profile picture", className: "cls_user_management_users_table_avatar_image" }), _jsx(AvatarFallback, { className: "cls_user_management_users_table_avatar_fallback bg-slate-200 text-slate-600 text-xs", children: getUserInitials(user) })] }) }), _jsxs(TableCell, { className: "cls_user_management_users_table_cell_id font-mono text-xs", children: [user.id.substring(0, 8), "..."] }), _jsx(TableCell, { className: "cls_user_management_users_table_cell_name", children: user.name || "-" }), _jsx(TableCell, { className: "cls_user_management_users_table_cell_email", children: user.email_address }), _jsx(TableCell, { className: "cls_user_management_users_table_cell_email_verified", children: user.email_verified ? (_jsx("span", { className: "text-green-600", children: "Yes" })) : (_jsx("span", { className: "text-red-600", children: "No" })) }), _jsx(TableCell, { className: "cls_user_management_users_table_cell_is_active", children: _jsxs("div", { className: "flex flex-col gap-0.5", children: [user.is_active ? (_jsx("span", { className: "text-green-600", children: "Active" })) : (_jsx("span", { className: "text-red-600", children: "Inactive" })), user.legal_acceptance_status !== 'none' && (_jsx("span", { className: user.legal_acceptance_status === 'current'
|
|
573
|
+
? 'text-green-600 text-xs font-medium'
|
|
574
|
+
: 'text-amber-600 text-xs font-medium', children: user.legal_acceptance_status === 'current' ? '✓ Legal' : '⚠ Legal' }))] }) }), _jsx(TableCell, { className: "cls_user_management_users_table_cell_last_logon", children: user.last_logon
|
|
575
|
+
? new Date(user.last_logon).toLocaleDateString()
|
|
576
|
+
: "-" }), _jsx(TableCell, { className: "cls_user_management_users_table_cell_created_at", children: user.created_at
|
|
577
|
+
? new Date(user.created_at).toLocaleDateString()
|
|
578
|
+
: "-" }), userTypesEnabled && (_jsx(TableCell, { className: "cls_user_management_users_table_cell_user_type", children: (() => {
|
|
579
|
+
const typeInfo = getUserTypeInfo(user.user_type);
|
|
580
|
+
return typeInfo ? (_jsx(UserTypeBadge, { label: typeInfo.label, color: typeInfo.badge_color })) : (_jsx("span", { className: "text-muted-foreground", children: "-" }));
|
|
581
|
+
})() })), _jsx(TableCell, { className: "cls_user_management_users_table_cell_actions text-right", children: _jsx(TooltipProvider, { children: _jsxs("div", { className: "cls_user_management_users_table_actions flex items-center justify-end gap-2", onClick: (e) => e.stopPropagation(), children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { onClick: () => {
|
|
582
|
+
setSelectedUser(user);
|
|
583
|
+
setAssignRolesDialogOpen(true);
|
|
584
|
+
}, variant: "outline", size: "sm", className: "cls_user_management_users_table_action_assign_roles", children: _jsx(UserPlus, { className: "h-4 w-4" }) }) }), _jsx(TooltipContent, { children: _jsx("p", { children: "Assign Roles" }) })] }), user.is_active && (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { onClick: () => {
|
|
585
|
+
setSelectedUser(user);
|
|
586
|
+
setDeactivateDialogOpen(true);
|
|
587
|
+
}, variant: "outline", size: "sm", className: "cls_user_management_users_table_action_deactivate", children: _jsx(UserX, { className: "h-4 w-4" }) }) }), _jsx(TooltipContent, { children: _jsx("p", { children: "Deactivate" }) })] })), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { onClick: () => {
|
|
588
|
+
setSelectedUser(user);
|
|
589
|
+
setResetPasswordDialogOpen(true);
|
|
590
|
+
}, variant: "outline", size: "sm", className: "cls_user_management_users_table_action_reset_password", children: _jsx(KeyRound, { className: "h-4 w-4" }) }) }), _jsx(TooltipContent, { children: _jsx("p", { children: "Reset Password" }) })] }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { onClick: () => {
|
|
591
|
+
setSelectedUser(user);
|
|
592
|
+
setDeleteDialogOpen(true);
|
|
593
|
+
}, variant: "outline", size: "sm", className: "cls_user_management_users_table_action_delete text-destructive", children: _jsx(Trash2, { className: "h-4 w-4" }) }) }), _jsx(TooltipContent, { children: _jsx("p", { children: "Delete User" }) })] })] }) }) })] }, user.id)))) })] }) }))] })), showRolesTab && (_jsx(TabsContent, { value: "roles", className: "cls_user_management_tab_roles w-full", children: _jsx(RolesMatrix, { add_button_enabled: true, role_name_selection_enabled: false, onSave: (data) => {
|
|
593
594
|
// Data is already saved by RolesMatrix component
|
|
594
595
|
console.log("Roles saved:", data);
|
|
595
596
|
} }) })), showPermissionsTab && (_jsx(TabsContent, { value: "permissions", className: "cls_user_management_tab_permissions w-full", children: _jsxs("div", { className: "cls_user_management_permissions_container flex flex-col gap-4 w-full", children: [_jsxs("div", { className: "cls_user_management_permissions_header flex items-center justify-between", children: [_jsx("div", { className: "cls_user_management_permissions_header_left flex items-center gap-2", children: _jsxs(Button, { onClick: () => setAddPermissionDialogOpen(true), variant: "default", size: "sm", className: "cls_user_management_permissions_add_button", children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), "Add Permission"] }) }), _jsx("div", { className: "cls_user_management_permissions_header_right", children: _jsx(Button, { onClick: handleMigratePermissions, disabled: migrateLoading, variant: "default", size: "sm", className: "cls_user_management_permissions_migrate_button", children: migrateLoading ? (_jsxs(_Fragment, { children: [_jsx(Loader2, { className: "h-4 w-4 mr-2 animate-spin" }), "Migrating..."] })) : ("Migrate config to database") }) })] }), permissionsLoading ? (_jsx("div", { className: "cls_user_management_permissions_loading flex items-center justify-center p-8", children: _jsx(Loader2, { className: "h-6 w-6 animate-spin text-slate-400" }) })) : (_jsx("div", { className: "cls_user_management_permissions_table_container border rounded-lg overflow-auto w-full", children: _jsxs(Table, { className: "cls_user_management_permissions_table w-full", children: [_jsx(TableHeader, { className: "cls_user_management_permissions_table_header", children: _jsxs(TableRow, { className: "cls_user_management_permissions_table_header_row", children: [_jsx(TableHead, { className: "cls_user_management_permissions_table_header_name", children: "Permission Name" }), _jsx(TableHead, { className: "cls_user_management_permissions_table_header_description", children: "Description" }), _jsx(TableHead, { className: "cls_user_management_permissions_table_header_source", children: "Source" }), _jsx(TableHead, { className: "cls_user_management_permissions_table_header_actions text-right", children: "Actions" })] }) }), _jsx(TableBody, { className: "cls_user_management_permissions_table_body", children: permissions.length === 0 ? (_jsx(TableRow, { className: "cls_user_management_permissions_table_row_empty", children: _jsx(TableCell, { colSpan: 4, className: "text-center text-muted-foreground py-8", children: "No permissions found." }) })) : (permissions.map((permission) => (_jsxs(TableRow, { className: "cls_user_management_permissions_table_row", children: [_jsx(TableCell, { className: `cls_user_management_permissions_table_cell_name font-medium ${permission.source === "db" ? "text-blue-600" : "text-purple-600"}`, children: permission.permission_name }), _jsx(TableCell, { className: "cls_user_management_permissions_table_cell_description", children: permission.description || "-" }), _jsx(TableCell, { className: "cls_user_management_permissions_table_cell_source", children: _jsx("span", { className: `px-2 py-1 rounded text-xs font-medium ${permission.source === "db"
|
|
@@ -7,7 +7,7 @@ declare const SheetClose: React.ForwardRefExoticComponent<SheetPrimitive.DialogC
|
|
|
7
7
|
declare const SheetPortal: React.FC<SheetPrimitive.DialogPortalProps>;
|
|
8
8
|
declare const SheetOverlay: React.ForwardRefExoticComponent<Omit<SheetPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
9
9
|
declare const SheetContent: React.ForwardRefExoticComponent<Omit<SheetPrimitive.DialogContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & VariantProps<(props?: ({
|
|
10
|
-
side?: "
|
|
10
|
+
side?: "top" | "bottom" | "left" | "right" | null | undefined;
|
|
11
11
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLDivElement>>;
|
|
12
12
|
declare const SheetHeader: {
|
|
13
13
|
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
@@ -11,6 +11,7 @@ export type HazoAuthUser = {
|
|
|
11
11
|
managed_by_user_id?: string | null;
|
|
12
12
|
app_user_data: Record<string, unknown> | null;
|
|
13
13
|
legal_acceptance: LegalAcceptanceMap | null;
|
|
14
|
+
preferred_locale: string | null;
|
|
14
15
|
};
|
|
15
16
|
/**
|
|
16
17
|
* Scope access information returned when scope checking is used
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth_types.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/auth_types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;GAEG;AACH,MAAM,MAA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AAY,EAAE;gBAD3B,QAAQ,EAAE,MAAM,EAChB,WAAW,GAAE,YAAY,EAAO;CAKnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hazo_get_auth.server.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/hazo_get_auth.server.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1C,OAAO,KAAK,EACV,cAAc,EAEd,eAAe,EAGhB,MAAM,cAAc,CAAC;AAgEtB;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAU1D;
|
|
1
|
+
{"version":3,"file":"hazo_get_auth.server.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/hazo_get_auth.server.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1C,OAAO,KAAK,EACV,cAAc,EAEd,eAAe,EAGhB,MAAM,cAAc,CAAC;AAgEtB;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAU1D;AA6SD;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,cAAc,CAAC,CA+NzB"}
|
|
@@ -153,6 +153,7 @@ async function fetch_user_data_from_db(user_id) {
|
|
|
153
153
|
managed_by_user_id: user_db.managed_by_user_id || null,
|
|
154
154
|
app_user_data: parse_app_user_data(user_db.app_user_data),
|
|
155
155
|
legal_acceptance: parse_legal_acceptance(user_db.legal_acceptance),
|
|
156
|
+
preferred_locale: user_db.preferred_locale || null,
|
|
156
157
|
};
|
|
157
158
|
// v5.x: Fetch user's roles from hazo_user_scopes (scope-based role assignments)
|
|
158
159
|
// Each scope assignment has a role_id (string UUID)
|
|
@@ -1 +1 @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AAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA0D/C"}
|
|
@@ -26,11 +26,13 @@ export async function handle_google_oauth_login(adapter, data) {
|
|
|
26
26
|
const users_by_google_id = await users_service.findBy({ google_id });
|
|
27
27
|
if (Array.isArray(users_by_google_id) && users_by_google_id.length > 0) {
|
|
28
28
|
const user = users_by_google_id[0];
|
|
29
|
-
// Update last_logon timestamp
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
// Update last_logon timestamp. Google is the source of truth for this
|
|
30
|
+
// user's avatar on this path (they just authenticated via Google, and
|
|
31
|
+
// google_id already matches), so refresh profile_picture_url whenever
|
|
32
|
+
// Google provides a truthy value — regardless of what's already stored.
|
|
33
|
+
// This handles CDN URL rotation, unlike Step 2/3's first-time-population
|
|
34
|
+
// guard (`!user.profile_picture_url && profile_picture_url`).
|
|
35
|
+
await users_service.updateById(user.id, Object.assign({ last_logon: now, changed_at: now }, (profile_picture_url ? { profile_picture_url, profile_source: "custom" } : {})));
|
|
34
36
|
logger.info("oauth_service_google_login_existing_google_user", {
|
|
35
37
|
filename: "oauth_service.ts",
|
|
36
38
|
line_number: get_line_number(),
|
|
@@ -182,7 +184,12 @@ export async function handle_facebook_oauth_login(adapter, data) {
|
|
|
182
184
|
const users_by_fb_id = await users_service.findBy({ facebook_id });
|
|
183
185
|
if (Array.isArray(users_by_fb_id) && users_by_fb_id.length > 0) {
|
|
184
186
|
const user = users_by_fb_id[0];
|
|
185
|
-
|
|
187
|
+
// Facebook is the source of truth for this user's avatar on this path
|
|
188
|
+
// (they just authenticated via Facebook, and facebook_id already
|
|
189
|
+
// matches), so refresh profile_picture_url whenever Facebook provides a
|
|
190
|
+
// truthy value — regardless of what's already stored. This handles CDN
|
|
191
|
+
// URL rotation, unlike Step 2/3's first-time-population guard.
|
|
192
|
+
await users_service.updateById(user.id, Object.assign({ last_logon: now, changed_at: now }, (profile_picture_url ? { profile_picture_url, profile_source: "custom" } : {})));
|
|
186
193
|
logger.info("oauth_service_facebook_login_existing_fb_user", {
|
|
187
194
|
filename: "oauth_service.ts",
|
|
188
195
|
user_id: user.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user_update_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/user_update_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAuB,KAAK,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAMnG,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,cAAc,CAAC,EAAE,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"user_update_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/user_update_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAuB,KAAK,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAMnG,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,cAAc,CAAC,EAAE,sBAAsB,CAAC;IAIxC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,gBAAgB,CAAC,CA4G3B"}
|
|
@@ -71,6 +71,10 @@ export async function update_user_profile(adapter, user_id, data) {
|
|
|
71
71
|
// Map UI source value to database enum value
|
|
72
72
|
update_data.profile_source = map_ui_source_to_db(data.profile_source);
|
|
73
73
|
}
|
|
74
|
+
if (data.preferred_locale !== undefined) {
|
|
75
|
+
// null explicitly clears the preference (falls back to detection elsewhere)
|
|
76
|
+
update_data.preferred_locale = data.preferred_locale;
|
|
77
|
+
}
|
|
74
78
|
// If email changed, set email_verified to false
|
|
75
79
|
if (email_changed) {
|
|
76
80
|
update_data.email_verified = false;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface SignupWindow {
|
|
2
|
+
/** stable key: 'all' | '7d' | '30d' | '90d' | '180d' | 'ytd' */
|
|
3
|
+
key: string;
|
|
4
|
+
/** short display label for the card */
|
|
5
|
+
label: string;
|
|
6
|
+
/** signups within the window ('all' = total users) */
|
|
7
|
+
count: number;
|
|
8
|
+
/** signups in the immediately-preceding equal-length period; null for 'all' */
|
|
9
|
+
prevCount: number | null;
|
|
10
|
+
/** rounded % change vs prevCount; null when prevCount is null or 0 */
|
|
11
|
+
pctChange: number | null;
|
|
12
|
+
}
|
|
13
|
+
export interface MonthlyPoint {
|
|
14
|
+
/** short month label, e.g. 'Jan' */
|
|
15
|
+
label: string;
|
|
16
|
+
/** signups created in that calendar month of the current year */
|
|
17
|
+
count: number;
|
|
18
|
+
}
|
|
19
|
+
export interface UserSignupStats {
|
|
20
|
+
total: number;
|
|
21
|
+
windows: SignupWindow[];
|
|
22
|
+
ytdMonthly: MonthlyPoint[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Compute signup stats from users' created_at values.
|
|
26
|
+
*
|
|
27
|
+
* Rolling windows (7/30/90/180 days) compare against the immediately-preceding
|
|
28
|
+
* equal-length period. YTD compares against the prior year's same-length
|
|
29
|
+
* period (year-to-date last year). Rows with missing/invalid created_at are
|
|
30
|
+
* ignored for window/YTD math but still counted in `total` via the raw length?
|
|
31
|
+
* — No: total counts only parseable timestamps so windows and total stay
|
|
32
|
+
* consistent. (Unparseable created_at should not happen for real users.)
|
|
33
|
+
*/
|
|
34
|
+
export declare function computeUserSignupStats(users: ReadonlyArray<{
|
|
35
|
+
created_at?: string | null;
|
|
36
|
+
}>, now?: Date): UserSignupStats;
|
|
37
|
+
//# sourceMappingURL=user_signup_stats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user_signup_stats.d.ts","sourceRoot":"","sources":["../../src/lib/user_signup_stats.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,gEAAgE;IAChE,GAAG,EAAE,MAAM,CAAC;IACZ,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,sEAAsE;IACtE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,UAAU,EAAE,YAAY,EAAE,CAAC;CAC5B;AAaD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,aAAa,CAAC;IAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,EACpD,GAAG,GAAE,IAAiB,GACrB,eAAe,CA+DjB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// file_description: Pure, dependency-free helpers to compute user-signup stats
|
|
2
|
+
// (rolling-window counts + % change vs the prior equal period, plus a YTD
|
|
3
|
+
// monthly series) from a list of users' created_at timestamps. Client-safe.
|
|
4
|
+
const DAY_MS = 86400000;
|
|
5
|
+
const MONTHS = [
|
|
6
|
+
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
|
7
|
+
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
|
8
|
+
];
|
|
9
|
+
function pctOf(count, prev) {
|
|
10
|
+
if (prev === null || prev === 0)
|
|
11
|
+
return null;
|
|
12
|
+
return Math.round(((count - prev) / prev) * 100);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Compute signup stats from users' created_at values.
|
|
16
|
+
*
|
|
17
|
+
* Rolling windows (7/30/90/180 days) compare against the immediately-preceding
|
|
18
|
+
* equal-length period. YTD compares against the prior year's same-length
|
|
19
|
+
* period (year-to-date last year). Rows with missing/invalid created_at are
|
|
20
|
+
* ignored for window/YTD math but still counted in `total` via the raw length?
|
|
21
|
+
* — No: total counts only parseable timestamps so windows and total stay
|
|
22
|
+
* consistent. (Unparseable created_at should not happen for real users.)
|
|
23
|
+
*/
|
|
24
|
+
export function computeUserSignupStats(users, now = new Date()) {
|
|
25
|
+
const nowMs = now.getTime();
|
|
26
|
+
const times = [];
|
|
27
|
+
for (const u of users) {
|
|
28
|
+
if (!u || !u.created_at)
|
|
29
|
+
continue;
|
|
30
|
+
const t = new Date(u.created_at).getTime();
|
|
31
|
+
if (!Number.isNaN(t))
|
|
32
|
+
times.push(t);
|
|
33
|
+
}
|
|
34
|
+
const countBetween = (startMs, endMs) => times.reduce((n, t) => (t >= startMs && t < endMs ? n + 1 : n), 0);
|
|
35
|
+
const total = times.length;
|
|
36
|
+
const rolling = [
|
|
37
|
+
{ key: "7d", label: "7 days", days: 7 },
|
|
38
|
+
{ key: "30d", label: "30 days", days: 30 },
|
|
39
|
+
{ key: "90d", label: "3 months", days: 90 },
|
|
40
|
+
{ key: "180d", label: "6 months", days: 180 },
|
|
41
|
+
];
|
|
42
|
+
const windows = [
|
|
43
|
+
{ key: "all", label: "All time", count: total, prevCount: null, pctChange: null },
|
|
44
|
+
];
|
|
45
|
+
for (const w of rolling) {
|
|
46
|
+
const span = w.days * DAY_MS;
|
|
47
|
+
const count = countBetween(nowMs - span, nowMs);
|
|
48
|
+
const prevCount = countBetween(nowMs - 2 * span, nowMs - span);
|
|
49
|
+
windows.push({
|
|
50
|
+
key: w.key,
|
|
51
|
+
label: w.label,
|
|
52
|
+
count,
|
|
53
|
+
prevCount,
|
|
54
|
+
pctChange: pctOf(count, prevCount),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// YTD vs prior-year YTD (same elapsed span in the previous year).
|
|
58
|
+
const ytdStart = new Date(now.getFullYear(), 0, 1).getTime();
|
|
59
|
+
const elapsed = nowMs - ytdStart;
|
|
60
|
+
const ytdCount = countBetween(ytdStart, nowMs);
|
|
61
|
+
const prevYtdStart = new Date(now.getFullYear() - 1, 0, 1).getTime();
|
|
62
|
+
const prevYtdCount = countBetween(prevYtdStart, prevYtdStart + elapsed);
|
|
63
|
+
windows.push({
|
|
64
|
+
key: "ytd",
|
|
65
|
+
label: "YTD",
|
|
66
|
+
count: ytdCount,
|
|
67
|
+
prevCount: prevYtdCount,
|
|
68
|
+
pctChange: pctOf(ytdCount, prevYtdCount),
|
|
69
|
+
});
|
|
70
|
+
// Monthly YTD series (Jan .. current month).
|
|
71
|
+
const ytdMonthly = [];
|
|
72
|
+
const year = now.getFullYear();
|
|
73
|
+
for (let m = 0; m <= now.getMonth(); m++) {
|
|
74
|
+
const monthStart = new Date(year, m, 1).getTime();
|
|
75
|
+
const monthEnd = new Date(year, m + 1, 1).getTime();
|
|
76
|
+
ytdMonthly.push({ label: MONTHS[m], count: countBetween(monthStart, monthEnd) });
|
|
77
|
+
}
|
|
78
|
+
return { total, windows, ytdMonthly };
|
|
79
|
+
}
|
|
@@ -11,11 +11,11 @@ export declare function GET(request: NextRequest): Promise<NextResponse<{
|
|
|
11
11
|
has_more: boolean;
|
|
12
12
|
total_pages: number;
|
|
13
13
|
};
|
|
14
|
-
source: "
|
|
14
|
+
source: "node_modules" | "project";
|
|
15
15
|
}> | NextResponse<{
|
|
16
16
|
success: boolean;
|
|
17
17
|
categories: string[];
|
|
18
|
-
source: "
|
|
18
|
+
source: "node_modules" | "project" | null;
|
|
19
19
|
}> | NextResponse<{
|
|
20
20
|
error: string;
|
|
21
21
|
}>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../src/server/routes/me.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoBxD;;;;;GAKG;AACH,wBAAsB,GAAG,CAAC,OAAO,EAAE,WAAW;;
|
|
1
|
+
{"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../src/server/routes/me.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoBxD;;;;;GAKG;AACH,wBAAsB,GAAG,CAAC,OAAO,EAAE,WAAW;;IAmH7C"}
|
package/dist/server/routes/me.js
CHANGED
|
@@ -24,7 +24,7 @@ function strip_sentinel_email(email) {
|
|
|
24
24
|
* Always returns the same format to prevent downstream variations.
|
|
25
25
|
*/
|
|
26
26
|
export async function GET(request) {
|
|
27
|
-
var _a;
|
|
27
|
+
var _a, _b;
|
|
28
28
|
const logger = create_app_logger();
|
|
29
29
|
try {
|
|
30
30
|
// Use hazo_get_auth to get user with permissions
|
|
@@ -97,6 +97,8 @@ export async function GET(request) {
|
|
|
97
97
|
app_user_data: auth_result.user.app_user_data,
|
|
98
98
|
// Legal documents the user has accepted (map of key -> { hash, accepted_at })
|
|
99
99
|
legal_acceptance: (_a = auth_result.user.legal_acceptance) !== null && _a !== void 0 ? _a : null,
|
|
100
|
+
// User's explicit locale preference (BCP 47 tag), or null if unset
|
|
101
|
+
preferred_locale: (_b = auth_result.user.preferred_locale) !== null && _b !== void 0 ? _b : null,
|
|
100
102
|
// Permissions and user object (always included)
|
|
101
103
|
user: auth_result.user,
|
|
102
104
|
permissions: auth_result.permissions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update_user.d.ts","sourceRoot":"","sources":["../../../src/server/routes/update_user.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"update_user.d.ts","sourceRoot":"","sources":["../../../src/server/routes/update_user.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA0BxD,wBAAsB,KAAK,CAAC,OAAO,EAAE,WAAW;;;;;;IAyI/C"}
|
|
@@ -7,6 +7,22 @@ import { update_user_profile } from "../../lib/services/user_update_service.js";
|
|
|
7
7
|
import { get_filename, get_line_number } from "../../lib/utils/api_route_helpers.js";
|
|
8
8
|
import { require_auth } from "../../lib/auth/auth_utils.server.js";
|
|
9
9
|
import { get_cookie_name, get_cookie_options, BASE_COOKIE_NAMES } from "../../lib/cookies_config.server.js";
|
|
10
|
+
// section: constants
|
|
11
|
+
// BCP 47 language tag, optionally followed by a region/script subtag
|
|
12
|
+
// (e.g. "en", "en-US", "pt-BR", "zh-Hans"). Deliberately NOT an allowlist — any
|
|
13
|
+
// syntactically valid tag is accepted, since the set of supported locales is owned
|
|
14
|
+
// by the consuming app, not hazo_auth.
|
|
15
|
+
const BCP47_LOCALE_REGEX = /^[a-z]{2,3}(-[A-Za-z]{2,4})?$/;
|
|
16
|
+
/**
|
|
17
|
+
* Validates a preferred_locale value from a PATCH body.
|
|
18
|
+
* @param value - Raw value from the request body
|
|
19
|
+
* @returns True if value is `null` (explicit clear) or a syntactically valid BCP 47 tag
|
|
20
|
+
*/
|
|
21
|
+
function is_valid_preferred_locale(value) {
|
|
22
|
+
if (value === null)
|
|
23
|
+
return true;
|
|
24
|
+
return typeof value === "string" && value.length <= 10 && BCP47_LOCALE_REGEX.test(value);
|
|
25
|
+
}
|
|
10
26
|
// section: api_handler
|
|
11
27
|
export async function PATCH(request) {
|
|
12
28
|
const logger = create_app_logger();
|
|
@@ -29,15 +45,28 @@ export async function PATCH(request) {
|
|
|
29
45
|
throw error;
|
|
30
46
|
}
|
|
31
47
|
const body = await request.json();
|
|
32
|
-
const { name, email, profile_picture_url, profile_source } = body;
|
|
48
|
+
const { name, email, profile_picture_url, profile_source, preferred_locale } = body;
|
|
33
49
|
// Validate input (at least one field must be provided)
|
|
34
|
-
if (name === undefined &&
|
|
50
|
+
if (name === undefined &&
|
|
51
|
+
email === undefined &&
|
|
52
|
+
profile_picture_url === undefined &&
|
|
53
|
+
preferred_locale === undefined) {
|
|
35
54
|
logger.warn("user_update_validation_failed", {
|
|
36
55
|
filename: get_filename(),
|
|
37
56
|
line_number: get_line_number(),
|
|
38
57
|
error: "No fields to update",
|
|
39
58
|
});
|
|
40
|
-
return NextResponse.json({ error: "At least one field (name, email, or
|
|
59
|
+
return NextResponse.json({ error: "At least one field (name, email, profile_picture_url, or preferred_locale) must be provided" }, { status: 400 });
|
|
60
|
+
}
|
|
61
|
+
// Validate preferred_locale (BCP 47 tag, or null to clear the preference)
|
|
62
|
+
if (preferred_locale !== undefined && !is_valid_preferred_locale(preferred_locale)) {
|
|
63
|
+
logger.warn("user_update_validation_failed", {
|
|
64
|
+
filename: get_filename(),
|
|
65
|
+
line_number: get_line_number(),
|
|
66
|
+
error: "Invalid preferred_locale",
|
|
67
|
+
preferred_locale,
|
|
68
|
+
});
|
|
69
|
+
return NextResponse.json({ error: "Invalid preferred_locale. Expected a BCP 47 locale tag (e.g. \"en\", \"pt-BR\") or null." }, { status: 400 });
|
|
41
70
|
}
|
|
42
71
|
// Get singleton hazo_connect instance
|
|
43
72
|
const hazoConnect = get_hazo_connect_instance();
|
|
@@ -47,6 +76,7 @@ export async function PATCH(request) {
|
|
|
47
76
|
email,
|
|
48
77
|
profile_picture_url,
|
|
49
78
|
profile_source,
|
|
79
|
+
preferred_locale,
|
|
50
80
|
});
|
|
51
81
|
if (!result.success) {
|
|
52
82
|
logger.warn("user_update_failed", {
|
package/legal/privacy.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Privacy Policy
|
|
2
|
+
|
|
3
|
+
Version: 1.0
|
|
4
|
+
|
|
5
|
+
_This is generic starter content shipped with hazo_auth's legal-docs
|
|
6
|
+
acceptance system. It is boilerplate, not legal advice — replace the
|
|
7
|
+
bracketed placeholders and have counsel review it before relying on it in
|
|
8
|
+
production, especially to confirm compliance with applicable laws such as
|
|
9
|
+
GDPR or CCPA._
|
|
10
|
+
|
|
11
|
+
## 1. Information We Collect
|
|
12
|
+
|
|
13
|
+
We collect information you provide directly, such as your name, email
|
|
14
|
+
address, and password (stored as a salted hash, never in plain text), along
|
|
15
|
+
with information generated by your use of the Service, such as login
|
|
16
|
+
timestamps, IP address, and usage activity.
|
|
17
|
+
|
|
18
|
+
## 2. How We Use It
|
|
19
|
+
|
|
20
|
+
We use the information we collect to provide, maintain, and improve the
|
|
21
|
+
Service; to authenticate you and secure your account; to communicate with
|
|
22
|
+
you about your account or the Service; and to comply with legal obligations.
|
|
23
|
+
|
|
24
|
+
## 3. Data Sharing
|
|
25
|
+
|
|
26
|
+
We do not sell your personal information. We may share information with
|
|
27
|
+
service providers who help us operate the Service (for example, hosting and
|
|
28
|
+
email delivery providers), each bound by confidentiality obligations, or
|
|
29
|
+
when required by law, to protect our rights, or in connection with a merger,
|
|
30
|
+
acquisition, or sale of assets.
|
|
31
|
+
|
|
32
|
+
## 4. Data Retention
|
|
33
|
+
|
|
34
|
+
We retain your information for as long as your account is active or as
|
|
35
|
+
needed to provide the Service. We may retain and use information as
|
|
36
|
+
necessary to comply with legal obligations, resolve disputes, and enforce
|
|
37
|
+
our agreements.
|
|
38
|
+
|
|
39
|
+
## 5. Your Rights
|
|
40
|
+
|
|
41
|
+
Depending on your jurisdiction, you may have the right to access, correct,
|
|
42
|
+
export, or delete your personal information, and to object to or restrict
|
|
43
|
+
certain processing. To exercise these rights, contact us using the details
|
|
44
|
+
below.
|
|
45
|
+
|
|
46
|
+
## 6. Cookies
|
|
47
|
+
|
|
48
|
+
We use cookies and similar technologies to keep you signed in, remember your
|
|
49
|
+
preferences, and understand how the Service is used. You can control cookies
|
|
50
|
+
through your browser settings, though disabling them may affect the
|
|
51
|
+
Service's functionality.
|
|
52
|
+
|
|
53
|
+
## 7. Changes to This Policy
|
|
54
|
+
|
|
55
|
+
We may update this Privacy Policy from time to time. If we make material
|
|
56
|
+
changes, we will provide notice (for example, by updating the "Version"
|
|
57
|
+
above or notifying you through the Service). Continued use of the Service
|
|
58
|
+
after changes take effect constitutes acceptance of the revised policy.
|
|
59
|
+
|
|
60
|
+
## 8. Contact
|
|
61
|
+
|
|
62
|
+
Questions about this Privacy Policy can be sent to
|
|
63
|
+
[privacy@yourcompany.example].
|
package/legal/tos.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Terms of Service
|
|
2
|
+
|
|
3
|
+
Version: 1.0
|
|
4
|
+
|
|
5
|
+
_This is generic starter content shipped with hazo_auth's legal-docs acceptance
|
|
6
|
+
system. It is boilerplate, not legal advice — replace the bracketed
|
|
7
|
+
placeholders and have counsel review it before relying on it in production._
|
|
8
|
+
|
|
9
|
+
## 1. Acceptance of Terms
|
|
10
|
+
|
|
11
|
+
By creating an account or otherwise using [Your Company Name]'s service (the
|
|
12
|
+
"Service"), you agree to be bound by these Terms of Service ("Terms"). If you
|
|
13
|
+
do not agree to these Terms, do not use the Service.
|
|
14
|
+
|
|
15
|
+
## 2. Use of Service
|
|
16
|
+
|
|
17
|
+
You may use the Service only for lawful purposes and in accordance with these
|
|
18
|
+
Terms. You agree not to use the Service in any way that violates any
|
|
19
|
+
applicable law or regulation, or that infringes the rights of, restricts, or
|
|
20
|
+
inhibits anyone else's use of the Service.
|
|
21
|
+
|
|
22
|
+
## 3. User Accounts
|
|
23
|
+
|
|
24
|
+
You are responsible for maintaining the confidentiality of your account
|
|
25
|
+
credentials and for all activity that occurs under your account. Notify us
|
|
26
|
+
immediately of any unauthorized use of your account. You must provide
|
|
27
|
+
accurate and complete information when creating an account and keep it up to
|
|
28
|
+
date.
|
|
29
|
+
|
|
30
|
+
## 4. Prohibited Uses
|
|
31
|
+
|
|
32
|
+
You agree not to: (a) reverse engineer, decompile, or attempt to extract the
|
|
33
|
+
source code of the Service, except where permitted by law; (b) interfere with
|
|
34
|
+
or disrupt the integrity or performance of the Service; (c) attempt to gain
|
|
35
|
+
unauthorized access to the Service or its related systems; (d) use the
|
|
36
|
+
Service to transmit any unlawful, harassing, defamatory, or infringing
|
|
37
|
+
content; or (e) use the Service in a manner that could damage, disable, or
|
|
38
|
+
impair it.
|
|
39
|
+
|
|
40
|
+
## 5. Termination
|
|
41
|
+
|
|
42
|
+
We may suspend or terminate your access to the Service at any time, with or
|
|
43
|
+
without cause or notice, including for conduct that we believe violates these
|
|
44
|
+
Terms or is harmful to other users, us, or third parties. You may stop using
|
|
45
|
+
the Service and close your account at any time.
|
|
46
|
+
|
|
47
|
+
## 6. Limitation of Liability
|
|
48
|
+
|
|
49
|
+
To the fullest extent permitted by law, [Your Company Name] and its
|
|
50
|
+
affiliates shall not be liable for any indirect, incidental, special,
|
|
51
|
+
consequential, or punitive damages, or any loss of profits or revenues,
|
|
52
|
+
whether incurred directly or indirectly, arising from your use of the
|
|
53
|
+
Service. The Service is provided "as is" and "as available" without
|
|
54
|
+
warranties of any kind, express or implied.
|
|
55
|
+
|
|
56
|
+
## 7. Changes to Terms
|
|
57
|
+
|
|
58
|
+
We may update these Terms from time to time. If we make material changes, we
|
|
59
|
+
will provide notice (for example, by updating the "Version" above or
|
|
60
|
+
notifying you through the Service). Continued use of the Service after
|
|
61
|
+
changes take effect constitutes acceptance of the revised Terms.
|
|
62
|
+
|
|
63
|
+
## 8. Contact
|
|
64
|
+
|
|
65
|
+
Questions about these Terms can be sent to [support@yourcompany.example].
|