hazo_auth 10.26.2 → 10.31.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_cache.ts +11 -1
- package/cli-src/lib/auth/auth_types.ts +6 -0
- package/cli-src/lib/auth/hazo_get_auth.server.ts +66 -8
- package/cli-src/lib/auth/hazo_get_tenant_auth.server.ts +9 -45
- package/cli-src/lib/auth/scope_header.ts +58 -0
- package/cli-src/lib/email_verification_config.server.ts +3 -0
- package/cli-src/lib/forgot_password_config.server.ts +3 -0
- package/cli-src/lib/register_config.server.ts +3 -0
- package/cli-src/lib/reset_password_config.server.ts +3 -0
- package/cli-src/lib/schema/sqlite_schema.ts +150 -38
- package/cli-src/lib/services/index.ts +1 -0
- package/cli-src/lib/services/registration_service.ts +29 -4
- package/cli-src/lib/services/scope_membership_service.ts +68 -0
- package/cli-src/lib/services/scope_service.ts +21 -0
- package/cli-src/lib/services/user_scope_service.ts +4 -32
- package/dist/components/layouts/email_verification/index.d.ts +3 -1
- package/dist/components/layouts/email_verification/index.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/index.js +4 -4
- package/dist/components/layouts/forgot_password/index.d.ts +3 -1
- package/dist/components/layouts/forgot_password/index.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/index.js +2 -2
- package/dist/components/layouts/register/hooks/use_register_form.d.ts +6 -1
- package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -1
- package/dist/components/layouts/register/hooks/use_register_form.js +4 -3
- package/dist/components/layouts/register/index.d.ts +7 -1
- package/dist/components/layouts/register/index.d.ts.map +1 -1
- package/dist/components/layouts/register/index.js +3 -2
- package/dist/components/layouts/reset_password/index.d.ts +3 -1
- package/dist/components/layouts/reset_password/index.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/index.js +5 -5
- package/dist/lib/auth/auth_cache.d.ts +6 -2
- package/dist/lib/auth/auth_cache.d.ts.map +1 -1
- package/dist/lib/auth/auth_cache.js +6 -2
- 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 +61 -8
- package/dist/lib/auth/hazo_get_tenant_auth.server.d.ts +2 -18
- package/dist/lib/auth/hazo_get_tenant_auth.server.d.ts.map +1 -1
- package/dist/lib/auth/hazo_get_tenant_auth.server.js +5 -38
- package/dist/lib/auth/scope_header.d.ts +28 -0
- package/dist/lib/auth/scope_header.d.ts.map +1 -0
- package/dist/lib/auth/scope_header.js +34 -0
- package/dist/lib/email_verification_config.server.d.ts +2 -0
- package/dist/lib/email_verification_config.server.d.ts.map +1 -1
- package/dist/lib/email_verification_config.server.js +1 -0
- package/dist/lib/forgot_password_config.server.d.ts +2 -0
- package/dist/lib/forgot_password_config.server.d.ts.map +1 -1
- package/dist/lib/forgot_password_config.server.js +1 -0
- package/dist/lib/register_config.server.d.ts +2 -0
- package/dist/lib/register_config.server.d.ts.map +1 -1
- package/dist/lib/register_config.server.js +1 -0
- package/dist/lib/reset_password_config.server.d.ts +2 -0
- package/dist/lib/reset_password_config.server.d.ts.map +1 -1
- package/dist/lib/reset_password_config.server.js +1 -0
- package/dist/lib/schema/sqlite_schema.d.ts +1 -1
- package/dist/lib/schema/sqlite_schema.d.ts.map +1 -1
- package/dist/lib/schema/sqlite_schema.js +150 -38
- package/dist/lib/services/index.d.ts +1 -0
- package/dist/lib/services/index.d.ts.map +1 -1
- package/dist/lib/services/index.js +1 -0
- package/dist/lib/services/registration_service.d.ts +11 -0
- package/dist/lib/services/registration_service.d.ts.map +1 -1
- package/dist/lib/services/registration_service.js +19 -5
- package/dist/lib/services/scope_membership_service.d.ts +20 -0
- package/dist/lib/services/scope_membership_service.d.ts.map +1 -0
- package/dist/lib/services/scope_membership_service.js +49 -0
- package/dist/lib/services/scope_service.d.ts +6 -0
- package/dist/lib/services/scope_service.d.ts.map +1 -1
- package/dist/lib/services/scope_service.js +12 -0
- package/dist/lib/services/user_scope_service.d.ts.map +1 -1
- package/dist/lib/services/user_scope_service.js +4 -30
- package/dist/server/routes/register.d.ts.map +1 -1
- package/dist/server/routes/register.js +7 -2
- package/dist/server/routes/user_management_users.d.ts +1 -1
- package/dist/server_pages/forgot_password.d.ts.map +1 -1
- package/dist/server_pages/forgot_password.js +1 -1
- package/dist/server_pages/forgot_password_client_wrapper.d.ts +1 -1
- package/dist/server_pages/forgot_password_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/forgot_password_client_wrapper.js +2 -2
- package/dist/server_pages/register.d.ts +19 -1
- package/dist/server_pages/register.d.ts.map +1 -1
- package/dist/server_pages/register.js +4 -4
- package/dist/server_pages/register_client_wrapper.d.ts +3 -1
- package/dist/server_pages/register_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/register_client_wrapper.js +2 -2
- package/dist/server_pages/reset_password.d.ts.map +1 -1
- package/dist/server_pages/reset_password.js +1 -1
- package/dist/server_pages/reset_password_client_wrapper.d.ts +1 -1
- package/dist/server_pages/reset_password_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/reset_password_client_wrapper.js +2 -2
- package/dist/server_pages/verify_email.d.ts.map +1 -1
- package/dist/server_pages/verify_email.js +1 -1
- package/dist/server_pages/verify_email_client_wrapper.d.ts +1 -1
- package/dist/server_pages/verify_email_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/verify_email_client_wrapper.js +2 -2
- package/package.json +13 -12
|
@@ -1,57 +1,59 @@
|
|
|
1
1
|
// file_description: canonical SQLite schema for hazo_auth database
|
|
2
2
|
// This is the single source of truth for the hazo_auth SQLite schema.
|
|
3
3
|
// Used by: npx hazo_auth init, npx hazo_auth init-db, npx hazo_auth schema
|
|
4
|
+
//
|
|
5
|
+
// Kept in lockstep with db_setup_sqlite.sql (same table/column/index set — that
|
|
6
|
+
// file is the human-readable reference copy, this is the one the CLI actually
|
|
7
|
+
// runs). __tests__/schema/sqlite_schema_canonical.test.ts asserts the two never
|
|
8
|
+
// drift again the way they did pre-10.30.1 (db_setup_sqlite.sql reflected all 26
|
|
9
|
+
// migrations; this constant was still frozen at migration ~14 and was missing
|
|
10
|
+
// hazo_role_permissions.changed_at, three whole tables, and several columns —
|
|
11
|
+
// see CHANGE_LOG 10.30.1).
|
|
4
12
|
|
|
5
13
|
export const SQLITE_SCHEMA = `
|
|
6
14
|
-- hazo_auth canonical SQLite schema
|
|
7
15
|
-- This schema creates all tables required by hazo_auth
|
|
16
|
+
-- Represents the FINAL schema state after all 26 migrations.
|
|
8
17
|
|
|
9
|
-
|
|
18
|
+
PRAGMA foreign_keys = ON;
|
|
19
|
+
|
|
20
|
+
-- Users table
|
|
10
21
|
CREATE TABLE IF NOT EXISTS hazo_users (
|
|
11
22
|
id TEXT PRIMARY KEY,
|
|
12
23
|
email_address TEXT NOT NULL UNIQUE,
|
|
13
24
|
password_hash TEXT,
|
|
14
25
|
name TEXT,
|
|
15
|
-
email_verified
|
|
16
|
-
login_attempts INTEGER DEFAULT 0,
|
|
26
|
+
email_verified INTEGER NOT NULL DEFAULT 0,
|
|
27
|
+
login_attempts INTEGER NOT NULL DEFAULT 0,
|
|
17
28
|
last_logon TEXT,
|
|
18
29
|
profile_picture_url TEXT,
|
|
19
30
|
profile_source TEXT CHECK(profile_source IN ('gravatar', 'custom', 'predefined')),
|
|
20
31
|
mfa_secret TEXT,
|
|
21
32
|
url_on_logon TEXT,
|
|
22
33
|
google_id TEXT UNIQUE,
|
|
23
|
-
auth_providers TEXT DEFAULT 'email',
|
|
34
|
+
auth_providers TEXT NOT NULL DEFAULT 'email',
|
|
24
35
|
user_type TEXT,
|
|
25
|
-
app_user_data TEXT,
|
|
26
|
-
status TEXT DEFAULT 'ACTIVE' CHECK(status IN ('PENDING', 'ACTIVE', 'BLOCKED')),
|
|
36
|
+
app_user_data TEXT NOT NULL DEFAULT '{}',
|
|
37
|
+
status TEXT NOT NULL DEFAULT 'ACTIVE' CHECK(status IN ('PENDING', 'ACTIVE', 'BLOCKED')),
|
|
27
38
|
managed_by_user_id TEXT REFERENCES hazo_users(id) ON DELETE SET NULL,
|
|
28
39
|
pin_hash TEXT,
|
|
40
|
+
facebook_id TEXT UNIQUE,
|
|
41
|
+
legal_acceptance TEXT NOT NULL DEFAULT '{}',
|
|
42
|
+
preferred_locale TEXT,
|
|
43
|
+
country TEXT,
|
|
44
|
+
state_province TEXT,
|
|
45
|
+
suburb TEXT,
|
|
29
46
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
30
47
|
changed_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
31
48
|
);
|
|
32
49
|
|
|
33
50
|
CREATE INDEX IF NOT EXISTS idx_hazo_users_email ON hazo_users(email_address);
|
|
34
51
|
CREATE INDEX IF NOT EXISTS idx_hazo_users_google_id ON hazo_users(google_id);
|
|
52
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_users_facebook_id ON hazo_users(facebook_id);
|
|
53
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_users_managed_by ON hazo_users(managed_by_user_id);
|
|
35
54
|
CREATE INDEX IF NOT EXISTS idx_hazo_users_status ON hazo_users(status);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
-- Note: runtime (token_service.ts) writes token_hash (argon2-hashed value) on
|
|
39
|
-
-- insert and verifies via argon2.verify(token_hash, plaintext_token) on read.
|
|
40
|
-
-- The plaintext "token" column is retained nullable for legacy compatibility
|
|
41
|
-
-- but new writes only set token_hash.
|
|
42
|
-
CREATE TABLE IF NOT EXISTS hazo_refresh_tokens (
|
|
43
|
-
id TEXT PRIMARY KEY,
|
|
44
|
-
user_id TEXT NOT NULL REFERENCES hazo_users(id) ON DELETE CASCADE,
|
|
45
|
-
token TEXT UNIQUE,
|
|
46
|
-
token_hash TEXT,
|
|
47
|
-
token_type TEXT DEFAULT 'refresh',
|
|
48
|
-
expires_at TEXT NOT NULL,
|
|
49
|
-
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
CREATE INDEX IF NOT EXISTS idx_hazo_refresh_tokens_user ON hazo_refresh_tokens(user_id);
|
|
53
|
-
CREATE INDEX IF NOT EXISTS idx_hazo_refresh_tokens_token ON hazo_refresh_tokens(token);
|
|
54
|
-
CREATE INDEX IF NOT EXISTS idx_hazo_refresh_tokens_token_hash ON hazo_refresh_tokens(token_hash);
|
|
55
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_users_country ON hazo_users(country);
|
|
56
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_users_state ON hazo_users(state_province);
|
|
55
57
|
|
|
56
58
|
-- Roles table
|
|
57
59
|
CREATE TABLE IF NOT EXISTS hazo_roles (
|
|
@@ -61,6 +63,8 @@ CREATE TABLE IF NOT EXISTS hazo_roles (
|
|
|
61
63
|
changed_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
62
64
|
);
|
|
63
65
|
|
|
66
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_roles_role_name ON hazo_roles(role_name);
|
|
67
|
+
|
|
64
68
|
-- Permissions table
|
|
65
69
|
CREATE TABLE IF NOT EXISTS hazo_permissions (
|
|
66
70
|
id TEXT PRIMARY KEY,
|
|
@@ -70,18 +74,56 @@ CREATE TABLE IF NOT EXISTS hazo_permissions (
|
|
|
70
74
|
changed_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
71
75
|
);
|
|
72
76
|
|
|
77
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_permissions_permission_name ON hazo_permissions(permission_name);
|
|
78
|
+
|
|
79
|
+
-- User-role assignments (composite PK, no id column)
|
|
80
|
+
CREATE TABLE IF NOT EXISTS hazo_user_roles (
|
|
81
|
+
user_id TEXT NOT NULL REFERENCES hazo_users(id) ON DELETE CASCADE,
|
|
82
|
+
role_id TEXT NOT NULL REFERENCES hazo_roles(id) ON DELETE CASCADE,
|
|
83
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
84
|
+
changed_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
85
|
+
PRIMARY KEY (user_id, role_id)
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_user_roles_user_id ON hazo_user_roles(user_id);
|
|
89
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_user_roles_role_id ON hazo_user_roles(role_id);
|
|
90
|
+
|
|
73
91
|
-- Role-permission assignments (composite PK, no id column)
|
|
74
92
|
CREATE TABLE IF NOT EXISTS hazo_role_permissions (
|
|
75
93
|
role_id TEXT NOT NULL REFERENCES hazo_roles(id) ON DELETE CASCADE,
|
|
76
94
|
permission_id TEXT NOT NULL REFERENCES hazo_permissions(id) ON DELETE CASCADE,
|
|
77
95
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
96
|
+
changed_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
78
97
|
PRIMARY KEY (role_id, permission_id)
|
|
79
98
|
);
|
|
80
99
|
|
|
100
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_role_permissions_role_id ON hazo_role_permissions(role_id);
|
|
101
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_role_permissions_permission_id ON hazo_role_permissions(permission_id);
|
|
102
|
+
|
|
103
|
+
-- Refresh tokens table
|
|
104
|
+
-- Note: runtime (token_service.ts) writes token_hash (argon2-hashed value) on
|
|
105
|
+
-- insert and verifies via argon2.verify(token_hash, plaintext_token) on read.
|
|
106
|
+
-- The plaintext "token" column is retained nullable for legacy compatibility
|
|
107
|
+
-- but new writes only set token_hash.
|
|
108
|
+
CREATE TABLE IF NOT EXISTS hazo_refresh_tokens (
|
|
109
|
+
id TEXT PRIMARY KEY,
|
|
110
|
+
user_id TEXT NOT NULL REFERENCES hazo_users(id) ON DELETE CASCADE,
|
|
111
|
+
token TEXT UNIQUE,
|
|
112
|
+
token_hash TEXT,
|
|
113
|
+
token_type TEXT NOT NULL DEFAULT 'refresh' CHECK (token_type IN ('refresh', 'password_reset', 'email_verification')),
|
|
114
|
+
expires_at TEXT NOT NULL,
|
|
115
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_refresh_tokens_user ON hazo_refresh_tokens(user_id);
|
|
119
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_refresh_tokens_token ON hazo_refresh_tokens(token);
|
|
120
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_refresh_tokens_token_hash ON hazo_refresh_tokens(token_hash);
|
|
121
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_refresh_tokens_expires_at ON hazo_refresh_tokens(expires_at);
|
|
122
|
+
|
|
81
123
|
-- Unified scopes table (hierarchical multi-tenancy)
|
|
82
124
|
CREATE TABLE IF NOT EXISTS hazo_scopes (
|
|
83
125
|
id TEXT PRIMARY KEY,
|
|
84
|
-
parent_id TEXT REFERENCES hazo_scopes(id) ON DELETE
|
|
126
|
+
parent_id TEXT REFERENCES hazo_scopes(id) ON DELETE SET NULL,
|
|
85
127
|
name TEXT NOT NULL,
|
|
86
128
|
level TEXT NOT NULL,
|
|
87
129
|
logo_url TEXT,
|
|
@@ -89,6 +131,11 @@ CREATE TABLE IF NOT EXISTS hazo_scopes (
|
|
|
89
131
|
secondary_color TEXT,
|
|
90
132
|
tagline TEXT,
|
|
91
133
|
slug TEXT,
|
|
134
|
+
subscription_id TEXT,
|
|
135
|
+
app_title TEXT,
|
|
136
|
+
footer_config TEXT,
|
|
137
|
+
timezone TEXT,
|
|
138
|
+
locale TEXT,
|
|
92
139
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
93
140
|
changed_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
94
141
|
);
|
|
@@ -96,6 +143,7 @@ CREATE TABLE IF NOT EXISTS hazo_scopes (
|
|
|
96
143
|
CREATE INDEX IF NOT EXISTS idx_hazo_scopes_parent ON hazo_scopes(parent_id);
|
|
97
144
|
CREATE INDEX IF NOT EXISTS idx_hazo_scopes_level ON hazo_scopes(level);
|
|
98
145
|
CREATE INDEX IF NOT EXISTS idx_hazo_scopes_slug ON hazo_scopes(slug);
|
|
146
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_scopes_subscription_id ON hazo_scopes(subscription_id);
|
|
99
147
|
|
|
100
148
|
-- Default system scope (for non-multi-tenancy mode)
|
|
101
149
|
INSERT OR IGNORE INTO hazo_scopes (id, parent_id, name, level, created_at, changed_at)
|
|
@@ -106,8 +154,8 @@ CREATE TABLE IF NOT EXISTS hazo_user_scopes (
|
|
|
106
154
|
user_id TEXT NOT NULL REFERENCES hazo_users(id) ON DELETE CASCADE,
|
|
107
155
|
scope_id TEXT NOT NULL REFERENCES hazo_scopes(id) ON DELETE CASCADE,
|
|
108
156
|
root_scope_id TEXT NOT NULL REFERENCES hazo_scopes(id) ON DELETE CASCADE,
|
|
109
|
-
role_id TEXT NOT NULL REFERENCES hazo_roles(id) ON DELETE
|
|
110
|
-
status TEXT DEFAULT 'ACTIVE' CHECK (status IN ('INVITED', 'ACTIVE', 'SUSPENDED', 'DEPARTED')),
|
|
157
|
+
role_id TEXT NOT NULL REFERENCES hazo_roles(id) ON DELETE RESTRICT,
|
|
158
|
+
status TEXT NOT NULL DEFAULT 'ACTIVE' CHECK (status IN ('INVITED', 'ACTIVE', 'SUSPENDED', 'DEPARTED')),
|
|
111
159
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
112
160
|
changed_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
113
161
|
PRIMARY KEY (user_id, scope_id)
|
|
@@ -122,9 +170,9 @@ CREATE TABLE IF NOT EXISTS hazo_invitations (
|
|
|
122
170
|
id TEXT PRIMARY KEY,
|
|
123
171
|
email_address TEXT NOT NULL,
|
|
124
172
|
token TEXT NOT NULL UNIQUE,
|
|
125
|
-
scope_id TEXT
|
|
126
|
-
root_scope_id TEXT
|
|
127
|
-
role_id TEXT
|
|
173
|
+
scope_id TEXT REFERENCES hazo_scopes(id) ON DELETE SET NULL,
|
|
174
|
+
root_scope_id TEXT REFERENCES hazo_scopes(id) ON DELETE SET NULL,
|
|
175
|
+
role_id TEXT REFERENCES hazo_roles(id) ON DELETE SET NULL,
|
|
128
176
|
invited_by TEXT REFERENCES hazo_users(id) ON DELETE SET NULL,
|
|
129
177
|
status TEXT NOT NULL DEFAULT 'PENDING' CHECK(status IN ('PENDING', 'ACCEPTED', 'EXPIRED', 'REVOKED')),
|
|
130
178
|
expires_at TEXT NOT NULL,
|
|
@@ -137,9 +185,6 @@ CREATE INDEX IF NOT EXISTS idx_hazo_invitations_email ON hazo_invitations(email_
|
|
|
137
185
|
CREATE INDEX IF NOT EXISTS idx_hazo_invitations_token ON hazo_invitations(token);
|
|
138
186
|
CREATE INDEX IF NOT EXISTS idx_hazo_invitations_scope ON hazo_invitations(scope_id);
|
|
139
187
|
CREATE INDEX IF NOT EXISTS idx_hazo_invitations_status ON hazo_invitations(status);
|
|
140
|
-
CREATE INDEX IF NOT EXISTS idx_hazo_invitations_expires ON hazo_invitations(expires_at);
|
|
141
|
-
|
|
142
|
-
CREATE INDEX IF NOT EXISTS idx_hazo_users_managed_by ON hazo_users(managed_by_user_id);
|
|
143
188
|
|
|
144
189
|
-- Relationships table
|
|
145
190
|
CREATE TABLE IF NOT EXISTS hazo_user_relationships (
|
|
@@ -147,10 +192,10 @@ CREATE TABLE IF NOT EXISTS hazo_user_relationships (
|
|
|
147
192
|
parent_user_id TEXT NOT NULL REFERENCES hazo_users(id) ON DELETE CASCADE,
|
|
148
193
|
child_user_id TEXT NOT NULL REFERENCES hazo_users(id) ON DELETE CASCADE,
|
|
149
194
|
relationship_type TEXT NOT NULL DEFAULT 'parent',
|
|
150
|
-
can_view_progress
|
|
151
|
-
can_edit_profile
|
|
152
|
-
can_delete
|
|
153
|
-
is_self
|
|
195
|
+
can_view_progress INTEGER NOT NULL DEFAULT 1,
|
|
196
|
+
can_edit_profile INTEGER NOT NULL DEFAULT 1,
|
|
197
|
+
can_delete INTEGER NOT NULL DEFAULT 0,
|
|
198
|
+
is_self INTEGER NOT NULL DEFAULT 0,
|
|
154
199
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
155
200
|
UNIQUE(parent_user_id, child_user_id)
|
|
156
201
|
);
|
|
@@ -158,6 +203,47 @@ CREATE TABLE IF NOT EXISTS hazo_user_relationships (
|
|
|
158
203
|
CREATE INDEX IF NOT EXISTS idx_hazo_user_relationships_parent ON hazo_user_relationships(parent_user_id);
|
|
159
204
|
CREATE INDEX IF NOT EXISTS idx_hazo_user_relationships_child ON hazo_user_relationships(child_user_id);
|
|
160
205
|
|
|
206
|
+
-- Email OTPs (migration 015)
|
|
207
|
+
CREATE TABLE IF NOT EXISTS hazo_email_otps (
|
|
208
|
+
id TEXT PRIMARY KEY,
|
|
209
|
+
user_id TEXT REFERENCES hazo_users(id) ON DELETE CASCADE,
|
|
210
|
+
email TEXT NOT NULL,
|
|
211
|
+
otp_hash TEXT NOT NULL,
|
|
212
|
+
expires_at TEXT NOT NULL,
|
|
213
|
+
consumed_at TEXT,
|
|
214
|
+
attempt_count INTEGER NOT NULL DEFAULT 0,
|
|
215
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
216
|
+
requester_ip TEXT
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_email_otps_user_id ON hazo_email_otps(user_id);
|
|
220
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_email_otps_email ON hazo_email_otps(email);
|
|
221
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_email_otps_expires_at ON hazo_email_otps(expires_at);
|
|
222
|
+
|
|
223
|
+
-- Legal acceptances (migration 018)
|
|
224
|
+
CREATE TABLE IF NOT EXISTS hazo_legal_acceptances (
|
|
225
|
+
id TEXT PRIMARY KEY,
|
|
226
|
+
user_id TEXT REFERENCES hazo_users(id) ON DELETE CASCADE,
|
|
227
|
+
doc_key TEXT NOT NULL,
|
|
228
|
+
doc_hash TEXT NOT NULL,
|
|
229
|
+
accepted_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
230
|
+
ip TEXT,
|
|
231
|
+
user_agent TEXT
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_legal_acceptances_user_id ON hazo_legal_acceptances(user_id);
|
|
235
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_legal_acceptances_doc_key ON hazo_legal_acceptances(doc_key);
|
|
236
|
+
|
|
237
|
+
-- Legal doc versions (migration 019)
|
|
238
|
+
CREATE TABLE IF NOT EXISTS hazo_legal_doc_versions (
|
|
239
|
+
doc_key TEXT PRIMARY KEY,
|
|
240
|
+
required_hash TEXT NOT NULL,
|
|
241
|
+
published_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
242
|
+
published_by_user_id TEXT REFERENCES hazo_users(id) ON DELETE SET NULL
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_legal_doc_versions_published_at ON hazo_legal_doc_versions(published_at);
|
|
246
|
+
|
|
161
247
|
-- Firm admin role (for firm creators)
|
|
162
248
|
INSERT OR IGNORE INTO hazo_roles (id, role_name, created_at, changed_at)
|
|
163
249
|
VALUES (lower(hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-4' || substr(hex(randomblob(2)),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(hex(randomblob(2)),2) || '-' || hex(randomblob(6))), 'firm_admin', datetime('now'), datetime('now'));
|
|
@@ -177,4 +263,30 @@ CREATE TABLE IF NOT EXISTS hazo_google_oauth_tokens (
|
|
|
177
263
|
);
|
|
178
264
|
|
|
179
265
|
CREATE INDEX IF NOT EXISTS idx_hazo_google_oauth_tokens_user ON hazo_google_oauth_tokens(user_id);
|
|
266
|
+
|
|
267
|
+
-- Groups + join codes (migration 024, ADR-0005)
|
|
268
|
+
CREATE TABLE IF NOT EXISTS hazo_groups (
|
|
269
|
+
id TEXT PRIMARY KEY,
|
|
270
|
+
scope_id TEXT NOT NULL REFERENCES hazo_scopes(id) ON DELETE CASCADE,
|
|
271
|
+
name TEXT NOT NULL,
|
|
272
|
+
join_code TEXT NOT NULL UNIQUE,
|
|
273
|
+
created_by TEXT REFERENCES hazo_users(id) ON DELETE SET NULL,
|
|
274
|
+
metadata TEXT,
|
|
275
|
+
status TEXT NOT NULL DEFAULT 'ACTIVE' CHECK (status IN ('ACTIVE', 'ARCHIVED')),
|
|
276
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
277
|
+
changed_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_groups_scope ON hazo_groups(scope_id);
|
|
281
|
+
|
|
282
|
+
CREATE TABLE IF NOT EXISTS hazo_group_memberships (
|
|
283
|
+
user_id TEXT NOT NULL REFERENCES hazo_users(id) ON DELETE CASCADE,
|
|
284
|
+
group_id TEXT NOT NULL REFERENCES hazo_groups(id) ON DELETE CASCADE,
|
|
285
|
+
role_id TEXT REFERENCES hazo_roles(id) ON DELETE SET NULL,
|
|
286
|
+
joined_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
287
|
+
status TEXT NOT NULL DEFAULT 'ACTIVE' CHECK (status IN ('ACTIVE', 'REMOVED')),
|
|
288
|
+
PRIMARY KEY (user_id, group_id)
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_group_memberships_group ON hazo_group_memberships(group_id);
|
|
180
292
|
`;
|
|
@@ -18,6 +18,7 @@ export * from "./firm_service.js";
|
|
|
18
18
|
export * from "./post_verification_service.js";
|
|
19
19
|
export * from "./scope_service.js";
|
|
20
20
|
export * from "./user_scope_service.js";
|
|
21
|
+
export * from "./scope_membership_service.js";
|
|
21
22
|
export * from "./group_service.js";
|
|
22
23
|
export * from "./oauth_service.js";
|
|
23
24
|
export * from "./branding_service.js";
|
|
@@ -15,6 +15,7 @@ import { get_filename, get_line_number } from "../utils/api_route_helpers.js";
|
|
|
15
15
|
import {
|
|
16
16
|
is_user_types_enabled,
|
|
17
17
|
get_default_user_type,
|
|
18
|
+
get_user_type_by_key,
|
|
18
19
|
} from "../user_types_config.server.js";
|
|
19
20
|
import { write_legal_acceptance } from "../legal/legal_docs_service.js";
|
|
20
21
|
import { fire_auth_hook } from "../auth_hooks.js";
|
|
@@ -38,6 +39,17 @@ export type RegistrationData = {
|
|
|
38
39
|
* existing `app_user_data` JSONB column via `update_app_user_data()` — no new
|
|
39
40
|
* column or config parser for these; see register_config.server.ts. */
|
|
40
41
|
custom_fields?: Record<string, unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* Explicit user type for this registration (e.g. a consumer with separate
|
|
44
|
+
* `/register/parent` and `/register/teacher` entry points, each setting a
|
|
45
|
+
* different type). Only takes effect when `[hazo_auth__user_types]`'s
|
|
46
|
+
* `enable_user_types` is on, and must match a configured `user_type_N` key
|
|
47
|
+
* — an unknown key fails the registration with `error: "Invalid user
|
|
48
|
+
* type"` rather than silently falling back to the config default.
|
|
49
|
+
* Omitted = fall back to `[hazo_auth__user_types].default_user_type`, same
|
|
50
|
+
* as before this field existed.
|
|
51
|
+
*/
|
|
52
|
+
user_type?: string;
|
|
41
53
|
};
|
|
42
54
|
|
|
43
55
|
export type RegistrationResult = {
|
|
@@ -123,11 +135,24 @@ export async function register_user(
|
|
|
123
135
|
}
|
|
124
136
|
}
|
|
125
137
|
|
|
126
|
-
// Set
|
|
138
|
+
// Set the user's type if the feature is enabled: an explicit `data.user_type`
|
|
139
|
+
// takes precedence over the configured default (validated against the
|
|
140
|
+
// configured type list either way — an unknown key is a registration
|
|
141
|
+
// error, not a silent fallback to the default).
|
|
127
142
|
if (is_user_types_enabled()) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
143
|
+
if (data.user_type !== undefined) {
|
|
144
|
+
if (!get_user_type_by_key(data.user_type)) {
|
|
145
|
+
return {
|
|
146
|
+
success: false,
|
|
147
|
+
error: "Invalid user type",
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
insert_data.user_type = data.user_type;
|
|
151
|
+
} else {
|
|
152
|
+
const default_type = get_default_user_type();
|
|
153
|
+
if (default_type) {
|
|
154
|
+
insert_data.user_type = default_type;
|
|
155
|
+
}
|
|
131
156
|
}
|
|
132
157
|
}
|
|
133
158
|
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// file_description: scope membership helpers for billing/workspace seat management
|
|
2
|
+
// (ticket 12 — HRBAC scope-aware permissions). Thin, camelCase wrappers around the
|
|
3
|
+
// existing snake_case hazo_user_scopes services, resolving their own HazoConnect
|
|
4
|
+
// instance so a consuming app's billing code (e.g. Team seat counting) doesn't need
|
|
5
|
+
// to plumb an adapter through — matches the ergonomics of hazo_pay's exported helpers
|
|
6
|
+
// (checkEntitlement, recordUsage) that this feature pairs with.
|
|
7
|
+
// section: imports
|
|
8
|
+
import "server-only";
|
|
9
|
+
|
|
10
|
+
import { createCrudService } from "hazo_connect/server";
|
|
11
|
+
import { get_hazo_connect_instance } from "../hazo_connect_instance.server.js";
|
|
12
|
+
import { get_user_scopes, get_users_by_scope, type UserScope } from "./user_scope_service.js";
|
|
13
|
+
|
|
14
|
+
// section: types
|
|
15
|
+
|
|
16
|
+
export type ScopeMember = {
|
|
17
|
+
user_id: string;
|
|
18
|
+
role_id: string;
|
|
19
|
+
/** hazo_users.status for this member — "ACTIVE" counts toward seat usage. */
|
|
20
|
+
status: string;
|
|
21
|
+
email_address: string | null;
|
|
22
|
+
name: string | null;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// section: helpers
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* All members (user + role) assigned to a scope, joined with their hazo_users
|
|
29
|
+
* status/email/name — the basis for Team seat management (ticket 13/18).
|
|
30
|
+
*/
|
|
31
|
+
export async function getScopeMembers(scopeId: string): Promise<ScopeMember[]> {
|
|
32
|
+
const adapter = get_hazo_connect_instance();
|
|
33
|
+
const result = await get_users_by_scope(adapter, scopeId);
|
|
34
|
+
if (!result.success || !result.scopes) {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const users_service = createCrudService(adapter, "hazo_users");
|
|
39
|
+
const members: ScopeMember[] = [];
|
|
40
|
+
|
|
41
|
+
for (const assignment of result.scopes) {
|
|
42
|
+
const users = await users_service.findBy({ id: assignment.user_id });
|
|
43
|
+
const user_row = Array.isArray(users) && users.length > 0 ? users[0] : null;
|
|
44
|
+
|
|
45
|
+
members.push({
|
|
46
|
+
user_id: assignment.user_id,
|
|
47
|
+
role_id: assignment.role_id,
|
|
48
|
+
status: (user_row?.status as string | undefined) ?? "UNKNOWN",
|
|
49
|
+
email_address: (user_row?.email_address as string | undefined) ?? null,
|
|
50
|
+
name: (user_row?.name as string | undefined) ?? null,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return members;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** All scope assignments for a user (every scope they belong to, with their role in each). */
|
|
58
|
+
export async function getUserScopes(userId: string): Promise<UserScope[]> {
|
|
59
|
+
const adapter = get_hazo_connect_instance();
|
|
60
|
+
const result = await get_user_scopes(adapter, userId);
|
|
61
|
+
return result.success && result.scopes ? result.scopes : [];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Count of ACTIVE members in a scope — the number of Team seats actually in use. */
|
|
65
|
+
export async function getSeatCount(scopeId: string): Promise<number> {
|
|
66
|
+
const members = await getScopeMembers(scopeId);
|
|
67
|
+
return members.filter((m) => m.status === "ACTIVE").length;
|
|
68
|
+
}
|
|
@@ -41,6 +41,9 @@ export type ScopeRecord = {
|
|
|
41
41
|
tagline: string | null;
|
|
42
42
|
app_title: string | null;
|
|
43
43
|
footer: { public?: FooterConfig; app?: FooterConfig } | null;
|
|
44
|
+
// Site-level defaults (migration 027). NULL means "no override set".
|
|
45
|
+
timezone: string | null;
|
|
46
|
+
locale: string | null;
|
|
44
47
|
created_at: string;
|
|
45
48
|
changed_at: string;
|
|
46
49
|
};
|
|
@@ -63,6 +66,9 @@ export type CreateScopeData = {
|
|
|
63
66
|
tagline?: string | null;
|
|
64
67
|
app_title?: string | null;
|
|
65
68
|
footer?: { public?: FooterConfig; app?: FooterConfig } | null;
|
|
69
|
+
// Site-level defaults (migration 027)
|
|
70
|
+
timezone?: string | null;
|
|
71
|
+
locale?: string | null;
|
|
66
72
|
};
|
|
67
73
|
|
|
68
74
|
export type UpdateScopeData = {
|
|
@@ -76,6 +82,9 @@ export type UpdateScopeData = {
|
|
|
76
82
|
tagline?: string | null;
|
|
77
83
|
app_title?: string | null;
|
|
78
84
|
footer?: { public?: FooterConfig; app?: FooterConfig } | null;
|
|
85
|
+
// Site-level defaults (migration 027)
|
|
86
|
+
timezone?: string | null;
|
|
87
|
+
locale?: string | null;
|
|
79
88
|
};
|
|
80
89
|
|
|
81
90
|
export type ScopeTreeNode = ScopeRecord & {
|
|
@@ -103,6 +112,8 @@ function normalize_scope_record(raw: Record<string, unknown>): ScopeRecord {
|
|
|
103
112
|
if (typeof raw_fc !== "string" || raw_fc.length === 0) return null;
|
|
104
113
|
try { return JSON.parse(raw_fc); } catch { return null; }
|
|
105
114
|
})(),
|
|
115
|
+
timezone: (raw.timezone as string | null) || null,
|
|
116
|
+
locale: (raw.locale as string | null) || null,
|
|
106
117
|
created_at: raw.created_at as string,
|
|
107
118
|
changed_at: raw.changed_at as string,
|
|
108
119
|
};
|
|
@@ -322,6 +333,8 @@ export async function create_scope(
|
|
|
322
333
|
tagline: data.tagline || null,
|
|
323
334
|
app_title: data.app_title || null,
|
|
324
335
|
footer_config: data.footer ? JSON.stringify(data.footer) : null,
|
|
336
|
+
timezone: data.timezone || null,
|
|
337
|
+
locale: data.locale || null,
|
|
325
338
|
created_at: now,
|
|
326
339
|
changed_at: now,
|
|
327
340
|
};
|
|
@@ -452,6 +465,12 @@ export async function update_scope(
|
|
|
452
465
|
if (data.footer !== undefined) {
|
|
453
466
|
update_data.footer_config = data.footer ? JSON.stringify(data.footer) : null;
|
|
454
467
|
}
|
|
468
|
+
if (data.timezone !== undefined) {
|
|
469
|
+
update_data.timezone = data.timezone;
|
|
470
|
+
}
|
|
471
|
+
if (data.locale !== undefined) {
|
|
472
|
+
update_data.locale = data.locale;
|
|
473
|
+
}
|
|
455
474
|
|
|
456
475
|
const updated = await scope_service.updateById(scope_id, update_data);
|
|
457
476
|
|
|
@@ -821,6 +840,8 @@ export async function ensure_default_system_scope(
|
|
|
821
840
|
tagline: null,
|
|
822
841
|
app_title: null,
|
|
823
842
|
footer_config: null,
|
|
843
|
+
timezone: null,
|
|
844
|
+
locale: null,
|
|
824
845
|
created_at: now,
|
|
825
846
|
changed_at: now,
|
|
826
847
|
});
|
|
@@ -237,38 +237,10 @@ export async function remove_user_scope(
|
|
|
237
237
|
|
|
238
238
|
const existing_scope = existing[0] as UserScope;
|
|
239
239
|
|
|
240
|
-
//
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
await user_scope_service.deleteById(
|
|
245
|
-
(existing[0] as Record<string, unknown>).id as string,
|
|
246
|
-
);
|
|
247
|
-
} else {
|
|
248
|
-
// For composite keys, we need to find and delete by all criteria
|
|
249
|
-
const all_user_scopes = await user_scope_service.findBy({ user_id });
|
|
250
|
-
if (Array.isArray(all_user_scopes)) {
|
|
251
|
-
for (const scope of all_user_scopes) {
|
|
252
|
-
const s = scope as UserScope;
|
|
253
|
-
if (s.scope_id === scope_id) {
|
|
254
|
-
if ((scope as Record<string, unknown>).id) {
|
|
255
|
-
await user_scope_service.deleteById(
|
|
256
|
-
(scope as Record<string, unknown>).id as string,
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
} catch {
|
|
265
|
-
const logger = create_app_logger();
|
|
266
|
-
logger.warn("user_scope_delete_fallback", {
|
|
267
|
-
filename: "user_scope_service.ts",
|
|
268
|
-
line_number: 0,
|
|
269
|
-
note: "Delete by composite key not fully supported",
|
|
270
|
-
});
|
|
271
|
-
}
|
|
240
|
+
// hazo_user_scopes has no `id` column — it uses a composite primary key
|
|
241
|
+
// (user_id, scope_id) — so delete by that composite key directly rather
|
|
242
|
+
// than through the single-key deleteById path.
|
|
243
|
+
await user_scope_service.deleteWhere({ user_id, scope_id });
|
|
272
244
|
|
|
273
245
|
return {
|
|
274
246
|
success: true,
|
|
@@ -19,7 +19,9 @@ export type EmailVerificationLayoutProps<TClient = unknown> = {
|
|
|
19
19
|
showReturnHomeButton?: boolean;
|
|
20
20
|
returnHomeButtonLabel?: string;
|
|
21
21
|
returnHomePath?: string;
|
|
22
|
+
/** `AlreadyLoggedInGuard`'s `redirectPath` prop. */
|
|
23
|
+
alreadyLoggedInRedirectPath?: string;
|
|
22
24
|
data_client: LayoutDataClient<TClient>;
|
|
23
25
|
};
|
|
24
|
-
export default function email_verification_layout<TClient>({ image_src, image_alt, image_background_color, field_overrides, labels, button_colors, success_labels, error_labels, redirect_delay, login_path, sign_in_label, data_client, already_logged_in_message, showLogoutButton, showReturnHomeButton, returnHomeButtonLabel, returnHomePath, }: EmailVerificationLayoutProps<TClient>): import("react").JSX.Element;
|
|
26
|
+
export default function email_verification_layout<TClient>({ image_src, image_alt, image_background_color, field_overrides, labels, button_colors, success_labels, error_labels, redirect_delay, login_path, sign_in_label, data_client, already_logged_in_message, showLogoutButton, showReturnHomeButton, returnHomeButtonLabel, returnHomePath, alreadyLoggedInRedirectPath, }: EmailVerificationLayoutProps<TClient>): import("react").JSX.Element;
|
|
25
27
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/email_verification/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAKlD,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAC1B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAOL,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EAClC,MAAM,0CAA0C,CAAC;AAKlD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAO1E,MAAM,MAAM,4BAA4B,CAAC,OAAO,GAAG,OAAO,IAAI;IAC5D,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,cAAc,CAAC,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC;IACzD,YAAY,CAAC,EAAE,OAAO,CAAC,4BAA4B,CAAC,CAAC;IACrD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;CACxC,CAAC;AASF,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,OAAO,EAAE,EACzD,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,eAAe,EACf,MAAM,EACN,aAAa,EACb,cAAc,EACd,YAAY,EACZ,cAAkB,EAClB,UAA+B,EAC/B,aAAa,EACb,WAAW,EACX,yBAAyB,EACzB,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqB,EACrB,cAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/email_verification/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAKlD,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAC1B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAOL,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EAClC,MAAM,0CAA0C,CAAC;AAKlD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAO1E,MAAM,MAAM,4BAA4B,CAAC,OAAO,GAAG,OAAO,IAAI;IAC5D,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,cAAc,CAAC,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC;IACzD,YAAY,CAAC,EAAE,OAAO,CAAC,4BAA4B,CAAC,CAAC;IACrD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oDAAoD;IACpD,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,WAAW,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;CACxC,CAAC;AASF,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,OAAO,EAAE,EACzD,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,eAAe,EACf,MAAM,EACN,aAAa,EACb,cAAc,EACd,YAAY,EACZ,cAAkB,EAClB,UAA+B,EAC/B,aAAa,EACb,WAAW,EACX,yBAAyB,EACzB,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqB,EACrB,cAAoB,EACpB,2BAA2B,GAC5B,EAAE,4BAA4B,CAAC,OAAO,CAAC,+BAyOvC"}
|
|
@@ -19,7 +19,7 @@ const ORDERED_FIELDS = [
|
|
|
19
19
|
EMAIL_VERIFICATION_FIELD_IDS.EMAIL,
|
|
20
20
|
];
|
|
21
21
|
// section: component
|
|
22
|
-
export default function email_verification_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, success_labels, error_labels, redirect_delay = 5, login_path = "/hazo_auth/login", sign_in_label, data_client, already_logged_in_message, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel, returnHomePath = "/", }) {
|
|
22
|
+
export default function email_verification_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, success_labels, error_labels, redirect_delay = 5, login_path = "/hazo_auth/login", sign_in_label, data_client, already_logged_in_message, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel, returnHomePath = "/", alreadyLoggedInRedirectPath, }) {
|
|
23
23
|
const t = useAuthT();
|
|
24
24
|
const resolvedSignInLabel = sign_in_label !== null && sign_in_label !== void 0 ? sign_in_label : t("shared.sign_in_default");
|
|
25
25
|
const resolvedReturnHomeButtonLabel = returnHomeButtonLabel !== null && returnHomeButtonLabel !== void 0 ? returnHomeButtonLabel : t("shared.guard.return_home_default");
|
|
@@ -52,15 +52,15 @@ export default function email_verification_layout({ image_src, image_alt, image_
|
|
|
52
52
|
};
|
|
53
53
|
// Verifying state
|
|
54
54
|
if (verification.isVerifying) {
|
|
55
|
-
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: already_logged_in_message, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, requireEmailVerified: false, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs("div", { className: "cls_email_verification_verifying flex flex-col items-center justify-center gap-4 py-8", children: [_jsx(Loader2, { className: "h-12 w-12 animate-spin text-slate-600", "aria-hidden": "true" }), _jsxs("div", { className: "cls_email_verification_verifying_text text-center", children: [_jsx("h1", { className: "cls_email_verification_verifying_heading text-2xl font-semibold text-slate-900", children: resolvedLabels.heading }), _jsx("p", { className: "cls_email_verification_verifying_subheading mt-2 text-sm text-slate-600", children: resolvedLabels.subHeading })] })] }) }) }));
|
|
55
|
+
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: already_logged_in_message, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, redirectPath: alreadyLoggedInRedirectPath, requireEmailVerified: false, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs("div", { className: "cls_email_verification_verifying flex flex-col items-center justify-center gap-4 py-8", children: [_jsx(Loader2, { className: "h-12 w-12 animate-spin text-slate-600", "aria-hidden": "true" }), _jsxs("div", { className: "cls_email_verification_verifying_text text-center", children: [_jsx("h1", { className: "cls_email_verification_verifying_heading text-2xl font-semibold text-slate-900", children: resolvedLabels.heading }), _jsx("p", { className: "cls_email_verification_verifying_subheading mt-2 text-sm text-slate-600", children: resolvedLabels.subHeading })] })] }) }) }));
|
|
56
56
|
}
|
|
57
57
|
// Success state
|
|
58
58
|
if (verification.isVerified) {
|
|
59
|
-
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: already_logged_in_message, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, requireEmailVerified: false, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs("div", { className: "cls_email_verification_success flex flex-col gap-6", children: [_jsxs("div", { className: "cls_email_verification_success_content flex flex-col items-center gap-4 text-center", children: [_jsx(CheckCircle, { className: "h-16 w-16 text-green-600", "aria-hidden": "true" }), _jsxs("div", { className: "cls_email_verification_success_text", children: [_jsx("h1", { className: "cls_email_verification_success_heading text-2xl font-semibold text-slate-900", children: resolvedSuccessLabels.heading }), _jsx("p", { className: "cls_email_verification_success_message mt-2 text-sm text-slate-600", children: resolvedSuccessLabels.message })] }), _jsxs("div", { className: "cls_email_verification_redirect_info mt-2 text-sm text-slate-500", children: [resolvedSuccessLabels.redirectMessage, " ", verification.redirectCountdown, " ", t("email_verification.redirect_seconds_suffix")] })] }), _jsx("div", { className: "cls_email_verification_success_actions flex justify-center", children: _jsx(Button, { type: "button", onClick: verification.handleGoToLogin, className: "cls_email_verification_go_to_login_button", style: {
|
|
59
|
+
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: already_logged_in_message, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, redirectPath: alreadyLoggedInRedirectPath, requireEmailVerified: false, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs("div", { className: "cls_email_verification_success flex flex-col gap-6", children: [_jsxs("div", { className: "cls_email_verification_success_content flex flex-col items-center gap-4 text-center", children: [_jsx(CheckCircle, { className: "h-16 w-16 text-green-600", "aria-hidden": "true" }), _jsxs("div", { className: "cls_email_verification_success_text", children: [_jsx("h1", { className: "cls_email_verification_success_heading text-2xl font-semibold text-slate-900", children: resolvedSuccessLabels.heading }), _jsx("p", { className: "cls_email_verification_success_message mt-2 text-sm text-slate-600", children: resolvedSuccessLabels.message })] }), _jsxs("div", { className: "cls_email_verification_redirect_info mt-2 text-sm text-slate-500", children: [resolvedSuccessLabels.redirectMessage, " ", verification.redirectCountdown, " ", t("email_verification.redirect_seconds_suffix")] })] }), _jsx("div", { className: "cls_email_verification_success_actions flex justify-center", children: _jsx(Button, { type: "button", onClick: verification.handleGoToLogin, className: "cls_email_verification_go_to_login_button", style: {
|
|
60
60
|
backgroundColor: resolvedButtonPalette.submitBackground,
|
|
61
61
|
color: resolvedButtonPalette.submitText,
|
|
62
62
|
}, children: resolvedSuccessLabels.goToLoginButton }) })] }) }) }));
|
|
63
63
|
}
|
|
64
64
|
// Error state with resend form
|
|
65
|
-
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: already_logged_in_message, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, requireEmailVerified: false, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs(_Fragment, { children: [_jsxs("div", { className: "cls_email_verification_error_header flex flex-col items-center gap-4 text-center", children: [_jsx(XCircle, { className: "h-12 w-12 text-red-600", "aria-hidden": "true" }), _jsxs("div", { className: "cls_email_verification_error_text", children: [_jsx("h1", { className: "cls_email_verification_error_heading text-2xl font-semibold text-slate-900", children: resolvedErrorLabels.heading }), _jsx("p", { className: "cls_email_verification_error_message mt-2 text-sm text-slate-600", children: verification.errorMessage || resolvedErrorLabels.message })] })] }), _jsxs("div", { className: "cls_email_verification_resend_form", children: [_jsx(FormHeader, { heading: resolvedErrorLabels.resendFormHeading, subHeading: t("email_verification.resend_email_prompt") }), _jsxs("form", { className: "cls_email_verification_layout_form_fields flex flex-col gap-5", onSubmit: verification.handleResendSubmit, "aria-label": t("email_verification.aria.resend_form"), children: [renderFields(verification), _jsx(FormActionButtons, { submitLabel: resolvedLabels.submitButton, cancelLabel: resolvedLabels.cancelButton, buttonPalette: resolvedButtonPalette, isSubmitDisabled: verification.isSubmitDisabled, onCancel: verification.handleCancel, submitAriaLabel: t("email_verification.aria.resend_submit"), cancelAriaLabel: t("email_verification.aria.resend_cancel") }), verification.isSubmitting && (_jsx("div", { className: "cls_email_verification_submitting_indicator text-sm text-slate-600 text-center", children: t("email_verification.sending_indicator") }))] }), _jsxs("div", { className: "cls_email_verification_sign_in_link mt-4 text-center text-sm text-slate-600", children: [t("email_verification.already_verified_prompt"), " ", _jsx(Link, { href: login_path, className: "font-medium text-slate-900 hover:underline", children: resolvedSignInLabel })] })] })] }) }) }));
|
|
65
|
+
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: already_logged_in_message, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, redirectPath: alreadyLoggedInRedirectPath, requireEmailVerified: false, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs(_Fragment, { children: [_jsxs("div", { className: "cls_email_verification_error_header flex flex-col items-center gap-4 text-center", children: [_jsx(XCircle, { className: "h-12 w-12 text-red-600", "aria-hidden": "true" }), _jsxs("div", { className: "cls_email_verification_error_text", children: [_jsx("h1", { className: "cls_email_verification_error_heading text-2xl font-semibold text-slate-900", children: resolvedErrorLabels.heading }), _jsx("p", { className: "cls_email_verification_error_message mt-2 text-sm text-slate-600", children: verification.errorMessage || resolvedErrorLabels.message })] })] }), _jsxs("div", { className: "cls_email_verification_resend_form", children: [_jsx(FormHeader, { heading: resolvedErrorLabels.resendFormHeading, subHeading: t("email_verification.resend_email_prompt") }), _jsxs("form", { className: "cls_email_verification_layout_form_fields flex flex-col gap-5", onSubmit: verification.handleResendSubmit, "aria-label": t("email_verification.aria.resend_form"), children: [renderFields(verification), _jsx(FormActionButtons, { submitLabel: resolvedLabels.submitButton, cancelLabel: resolvedLabels.cancelButton, buttonPalette: resolvedButtonPalette, isSubmitDisabled: verification.isSubmitDisabled, onCancel: verification.handleCancel, submitAriaLabel: t("email_verification.aria.resend_submit"), cancelAriaLabel: t("email_verification.aria.resend_cancel") }), verification.isSubmitting && (_jsx("div", { className: "cls_email_verification_submitting_indicator text-sm text-slate-600 text-center", children: t("email_verification.sending_indicator") }))] }), _jsxs("div", { className: "cls_email_verification_sign_in_link mt-4 text-center text-sm text-slate-600", children: [t("email_verification.already_verified_prompt"), " ", _jsx(Link, { href: login_path, className: "font-medium text-slate-900 hover:underline", children: resolvedSignInLabel })] })] })] }) }) }));
|
|
66
66
|
}
|
|
@@ -16,6 +16,8 @@ export type ForgotPasswordLayoutProps<TClient = unknown> = {
|
|
|
16
16
|
showReturnHomeButton?: boolean;
|
|
17
17
|
returnHomeButtonLabel?: string;
|
|
18
18
|
returnHomePath?: string;
|
|
19
|
+
/** `AlreadyLoggedInGuard`'s `redirectPath` prop. */
|
|
20
|
+
alreadyLoggedInRedirectPath?: string;
|
|
19
21
|
/** Message shown when user's account is Google-only (no password set) */
|
|
20
22
|
googleOnlyAccountHeading?: string;
|
|
21
23
|
googleOnlyAccountMessage?: string;
|
|
@@ -23,5 +25,5 @@ export type ForgotPasswordLayoutProps<TClient = unknown> = {
|
|
|
23
25
|
mySettingsPath?: string;
|
|
24
26
|
mySettingsLabel?: string;
|
|
25
27
|
};
|
|
26
|
-
export default function forgot_password_layout<TClient>({ image_src, image_alt, image_background_color, field_overrides, labels, button_colors, data_client, sign_in_path, sign_in_label, alreadyLoggedInMessage, showLogoutButton, showReturnHomeButton, returnHomeButtonLabel, returnHomePath, googleOnlyAccountHeading, googleOnlyAccountMessage, googleOnlyAccountHelpText, mySettingsPath, mySettingsLabel, }: ForgotPasswordLayoutProps<TClient>): import("react").JSX.Element;
|
|
28
|
+
export default function forgot_password_layout<TClient>({ image_src, image_alt, image_background_color, field_overrides, labels, button_colors, data_client, sign_in_path, sign_in_label, alreadyLoggedInMessage, showLogoutButton, showReturnHomeButton, returnHomeButtonLabel, returnHomePath, alreadyLoggedInRedirectPath, googleOnlyAccountHeading, googleOnlyAccountMessage, googleOnlyAccountHelpText, mySettingsPath, mySettingsLabel, }: ForgotPasswordLayoutProps<TClient>): import("react").JSX.Element;
|
|
27
29
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/forgot_password/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAOlD,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAC1B,MAAM,uCAAuC,CAAC;AAW/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAK1E,MAAM,MAAM,yBAAyB,CAAC,OAAO,GAAG,OAAO,IAAI;IACzD,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,WAAW,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AASF,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,OAAO,EAAE,EACtD,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,eAAe,EACf,MAAM,EACN,aAAa,EACb,WAAW,EACX,YAAiC,EACjC,aAAa,EACb,sBAAsB,EACtB,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqB,EACrB,cAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EACzB,cAAyC,EACzC,eAAe,GAChB,EAAE,yBAAyB,CAAC,OAAO,CAAC,+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/forgot_password/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAOlD,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAC1B,MAAM,uCAAuC,CAAC;AAW/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAK1E,MAAM,MAAM,yBAAyB,CAAC,OAAO,GAAG,OAAO,IAAI;IACzD,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,WAAW,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oDAAoD;IACpD,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,yEAAyE;IACzE,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AASF,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,OAAO,EAAE,EACtD,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,eAAe,EACf,MAAM,EACN,aAAa,EACb,WAAW,EACX,YAAiC,EACjC,aAAa,EACb,sBAAsB,EACtB,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqB,EACrB,cAAoB,EACpB,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EACzB,cAAyC,EACzC,eAAe,GAChB,EAAE,yBAAyB,CAAC,OAAO,CAAC,+BA8JpC"}
|