hazo_auth 5.1.3 → 5.1.4
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 +1 -1
- package/cli-src/lib/auth/auth_utils.server.ts +6 -6
- package/cli-src/lib/auth/hazo_get_auth.server.ts +3 -3
- package/cli-src/lib/auth/server_auth.ts +3 -3
- package/cli-src/lib/services/login_service.ts +2 -2
- package/cli-src/lib/services/oauth_service.ts +1 -1
- package/cli-src/lib/services/registration_service.ts +1 -1
- package/dist/lib/auth/auth_utils.server.js +6 -6
- package/dist/lib/auth/hazo_get_auth.server.js +3 -3
- package/dist/lib/auth/server_auth.js +3 -3
- package/dist/lib/services/login_service.js +2 -2
- package/dist/lib/services/oauth_service.js +1 -1
- package/dist/lib/services/registration_service.js +1 -1
- package/dist/server/routes/user_management_users.d.ts +1 -1
- package/dist/server/routes/user_management_users.js +3 -3
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ export type HazoAuthUser = {
|
|
|
8
8
|
id: string;
|
|
9
9
|
name: string | null;
|
|
10
10
|
email_address: string;
|
|
11
|
-
is_active: boolean; // Derived from status column: status === '
|
|
11
|
+
is_active: boolean; // Derived from status column: status === 'ACTIVE'
|
|
12
12
|
profile_picture_url: string | null;
|
|
13
13
|
// App-specific user data (JSON object stored as TEXT in database)
|
|
14
14
|
app_user_data: Record<string, unknown> | null;
|
|
@@ -69,8 +69,8 @@ export async function get_authenticated_user(request: NextRequest): Promise<Auth
|
|
|
69
69
|
|
|
70
70
|
const user = users[0];
|
|
71
71
|
|
|
72
|
-
// Check if user is active (status must be '
|
|
73
|
-
if (user.status !== "
|
|
72
|
+
// Check if user is active (status must be 'ACTIVE')
|
|
73
|
+
if (user.status !== "ACTIVE") {
|
|
74
74
|
return { authenticated: false };
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -84,7 +84,7 @@ export async function get_authenticated_user(request: NextRequest): Promise<Auth
|
|
|
84
84
|
email: user.email_address as string,
|
|
85
85
|
name: (user.name as string | null | undefined) || undefined,
|
|
86
86
|
email_verified: user.email_verified === true,
|
|
87
|
-
is_active: user.status === "
|
|
87
|
+
is_active: user.status === "ACTIVE", // Derived from status column
|
|
88
88
|
last_logon: (user.last_logon as string | null | undefined) || undefined,
|
|
89
89
|
profile_picture_url: (user.profile_picture_url as string | null | undefined) || undefined,
|
|
90
90
|
profile_source: profile_source_ui,
|
|
@@ -159,8 +159,8 @@ export async function get_authenticated_user_with_response(request: NextRequest)
|
|
|
159
159
|
|
|
160
160
|
const user = users[0];
|
|
161
161
|
|
|
162
|
-
// Check if user is still active (status must be '
|
|
163
|
-
if (user.status !== "
|
|
162
|
+
// Check if user is still active (status must be 'ACTIVE')
|
|
163
|
+
if (user.status !== "ACTIVE") {
|
|
164
164
|
// User is inactive - clear cookies
|
|
165
165
|
const response = NextResponse.json(
|
|
166
166
|
{ authenticated: false },
|
|
@@ -181,7 +181,7 @@ export async function get_authenticated_user_with_response(request: NextRequest)
|
|
|
181
181
|
email: user.email_address as string,
|
|
182
182
|
name: (user.name as string | null | undefined) || undefined,
|
|
183
183
|
email_verified: user.email_verified === true,
|
|
184
|
-
is_active: user.status === "
|
|
184
|
+
is_active: user.status === "ACTIVE", // Derived from status column
|
|
185
185
|
last_logon: (user.last_logon as string | null | undefined) || undefined,
|
|
186
186
|
profile_picture_url: (user.profile_picture_url as string | null | undefined) || undefined,
|
|
187
187
|
profile_source: profile_source_ui,
|
|
@@ -102,8 +102,8 @@ async function fetch_user_data_from_db(user_id: string): Promise<{
|
|
|
102
102
|
|
|
103
103
|
const user_db = users[0];
|
|
104
104
|
|
|
105
|
-
// Check if user is active (status must be '
|
|
106
|
-
if (user_db.status !== "
|
|
105
|
+
// Check if user is active (status must be 'ACTIVE')
|
|
106
|
+
if (user_db.status !== "ACTIVE") {
|
|
107
107
|
throw new Error("User is inactive");
|
|
108
108
|
}
|
|
109
109
|
|
|
@@ -112,7 +112,7 @@ async function fetch_user_data_from_db(user_id: string): Promise<{
|
|
|
112
112
|
id: user_db.id as string,
|
|
113
113
|
name: (user_db.name as string | null) || null,
|
|
114
114
|
email_address: user_db.email_address as string,
|
|
115
|
-
is_active: user_db.status === "
|
|
115
|
+
is_active: user_db.status === "ACTIVE", // Derived from status column
|
|
116
116
|
profile_picture_url:
|
|
117
117
|
(user_db.profile_picture_url as string | null) || null,
|
|
118
118
|
app_user_data: parse_app_user_data(user_db.app_user_data),
|
|
@@ -53,8 +53,8 @@ export async function get_server_auth_user(): Promise<ServerAuthResult> {
|
|
|
53
53
|
|
|
54
54
|
const user = users[0];
|
|
55
55
|
|
|
56
|
-
// Check if user is active (status must be '
|
|
57
|
-
if (user.status !== "
|
|
56
|
+
// Check if user is active (status must be 'ACTIVE')
|
|
57
|
+
if (user.status !== "ACTIVE") {
|
|
58
58
|
return { authenticated: false };
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -68,7 +68,7 @@ export async function get_server_auth_user(): Promise<ServerAuthResult> {
|
|
|
68
68
|
email: user.email_address as string,
|
|
69
69
|
name: (user.name as string | null | undefined) || undefined,
|
|
70
70
|
email_verified: user.email_verified === true,
|
|
71
|
-
is_active: user.status === "
|
|
71
|
+
is_active: user.status === "ACTIVE", // Derived from status column
|
|
72
72
|
last_logon: (user.last_logon as string | null | undefined) || undefined,
|
|
73
73
|
profile_picture_url: (user.profile_picture_url as string | null | undefined) || undefined,
|
|
74
74
|
profile_source: profile_source_ui,
|
|
@@ -53,8 +53,8 @@ export async function authenticate_user(
|
|
|
53
53
|
|
|
54
54
|
const user = users[0];
|
|
55
55
|
|
|
56
|
-
// Check if user is active (status must be '
|
|
57
|
-
if (user.status !== "
|
|
56
|
+
// Check if user is active (status must be 'ACTIVE')
|
|
57
|
+
if (user.status !== "ACTIVE") {
|
|
58
58
|
return {
|
|
59
59
|
success: false,
|
|
60
60
|
error: "Account is inactive. Please contact support.",
|
|
@@ -179,7 +179,7 @@ export async function handle_google_oauth_login(
|
|
|
179
179
|
email_address: email,
|
|
180
180
|
password_hash: "", // Empty string for Google-only users
|
|
181
181
|
email_verified: email_verified, // Trust Google's verification
|
|
182
|
-
status: "
|
|
182
|
+
status: "ACTIVE",
|
|
183
183
|
login_attempts: 0,
|
|
184
184
|
google_id,
|
|
185
185
|
auth_providers: "google",
|
|
@@ -73,7 +73,7 @@ export async function register_user(
|
|
|
73
73
|
email_address: email,
|
|
74
74
|
password_hash: password_hash,
|
|
75
75
|
email_verified: false,
|
|
76
|
-
status: "
|
|
76
|
+
status: "ACTIVE",
|
|
77
77
|
login_attempts: 0,
|
|
78
78
|
auth_providers: "email", // Track that this user registered with email/password
|
|
79
79
|
created_at: now,
|
|
@@ -45,8 +45,8 @@ export async function get_authenticated_user(request) {
|
|
|
45
45
|
return { authenticated: false };
|
|
46
46
|
}
|
|
47
47
|
const user = users[0];
|
|
48
|
-
// Check if user is active (status must be '
|
|
49
|
-
if (user.status !== "
|
|
48
|
+
// Check if user is active (status must be 'ACTIVE')
|
|
49
|
+
if (user.status !== "ACTIVE") {
|
|
50
50
|
return { authenticated: false };
|
|
51
51
|
}
|
|
52
52
|
// Map database profile_source to UI representation
|
|
@@ -58,7 +58,7 @@ export async function get_authenticated_user(request) {
|
|
|
58
58
|
email: user.email_address,
|
|
59
59
|
name: user.name || undefined,
|
|
60
60
|
email_verified: user.email_verified === true,
|
|
61
|
-
is_active: user.status === "
|
|
61
|
+
is_active: user.status === "ACTIVE", // Derived from status column
|
|
62
62
|
last_logon: user.last_logon || undefined,
|
|
63
63
|
profile_picture_url: user.profile_picture_url || undefined,
|
|
64
64
|
profile_source: profile_source_ui,
|
|
@@ -118,8 +118,8 @@ export async function get_authenticated_user_with_response(request) {
|
|
|
118
118
|
return { auth_result: { authenticated: false }, response };
|
|
119
119
|
}
|
|
120
120
|
const user = users[0];
|
|
121
|
-
// Check if user is still active (status must be '
|
|
122
|
-
if (user.status !== "
|
|
121
|
+
// Check if user is still active (status must be 'ACTIVE')
|
|
122
|
+
if (user.status !== "ACTIVE") {
|
|
123
123
|
// User is inactive - clear cookies
|
|
124
124
|
const response = NextResponse.json({ authenticated: false }, { status: 200 });
|
|
125
125
|
clear_auth_cookies(response);
|
|
@@ -135,7 +135,7 @@ export async function get_authenticated_user_with_response(request) {
|
|
|
135
135
|
email: user.email_address,
|
|
136
136
|
name: user.name || undefined,
|
|
137
137
|
email_verified: user.email_verified === true,
|
|
138
|
-
is_active: user.status === "
|
|
138
|
+
is_active: user.status === "ACTIVE", // Derived from status column
|
|
139
139
|
last_logon: user.last_logon || undefined,
|
|
140
140
|
profile_picture_url: user.profile_picture_url || undefined,
|
|
141
141
|
profile_source: profile_source_ui,
|
|
@@ -69,8 +69,8 @@ async function fetch_user_data_from_db(user_id) {
|
|
|
69
69
|
throw new Error("User not found");
|
|
70
70
|
}
|
|
71
71
|
const user_db = users[0];
|
|
72
|
-
// Check if user is active (status must be '
|
|
73
|
-
if (user_db.status !== "
|
|
72
|
+
// Check if user is active (status must be 'ACTIVE')
|
|
73
|
+
if (user_db.status !== "ACTIVE") {
|
|
74
74
|
throw new Error("User is inactive");
|
|
75
75
|
}
|
|
76
76
|
// Build user object
|
|
@@ -78,7 +78,7 @@ async function fetch_user_data_from_db(user_id) {
|
|
|
78
78
|
id: user_db.id,
|
|
79
79
|
name: user_db.name || null,
|
|
80
80
|
email_address: user_db.email_address,
|
|
81
|
-
is_active: user_db.status === "
|
|
81
|
+
is_active: user_db.status === "ACTIVE", // Derived from status column
|
|
82
82
|
profile_picture_url: user_db.profile_picture_url || null,
|
|
83
83
|
app_user_data: parse_app_user_data(user_db.app_user_data),
|
|
84
84
|
};
|
|
@@ -30,8 +30,8 @@ export async function get_server_auth_user() {
|
|
|
30
30
|
return { authenticated: false };
|
|
31
31
|
}
|
|
32
32
|
const user = users[0];
|
|
33
|
-
// Check if user is active (status must be '
|
|
34
|
-
if (user.status !== "
|
|
33
|
+
// Check if user is active (status must be 'ACTIVE')
|
|
34
|
+
if (user.status !== "ACTIVE") {
|
|
35
35
|
return { authenticated: false };
|
|
36
36
|
}
|
|
37
37
|
// Map database profile_source to UI representation
|
|
@@ -43,7 +43,7 @@ export async function get_server_auth_user() {
|
|
|
43
43
|
email: user.email_address,
|
|
44
44
|
name: user.name || undefined,
|
|
45
45
|
email_verified: user.email_verified === true,
|
|
46
|
-
is_active: user.status === "
|
|
46
|
+
is_active: user.status === "ACTIVE", // Derived from status column
|
|
47
47
|
last_logon: user.last_logon || undefined,
|
|
48
48
|
profile_picture_url: user.profile_picture_url || undefined,
|
|
49
49
|
profile_source: profile_source_ui,
|
|
@@ -27,8 +27,8 @@ export async function authenticate_user(adapter, data) {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
const user = users[0];
|
|
30
|
-
// Check if user is active (status must be '
|
|
31
|
-
if (user.status !== "
|
|
30
|
+
// Check if user is active (status must be 'ACTIVE')
|
|
31
|
+
if (user.status !== "ACTIVE") {
|
|
32
32
|
return {
|
|
33
33
|
success: false,
|
|
34
34
|
error: "Account is inactive. Please contact support.",
|
|
@@ -112,7 +112,7 @@ export async function handle_google_oauth_login(adapter, data) {
|
|
|
112
112
|
email_address: email,
|
|
113
113
|
password_hash: "", // Empty string for Google-only users
|
|
114
114
|
email_verified: email_verified, // Trust Google's verification
|
|
115
|
-
status: "
|
|
115
|
+
status: "ACTIVE",
|
|
116
116
|
login_attempts: 0,
|
|
117
117
|
google_id,
|
|
118
118
|
auth_providers: "google",
|
|
@@ -43,7 +43,7 @@ export async function register_user(adapter, data) {
|
|
|
43
43
|
email_address: email,
|
|
44
44
|
password_hash: password_hash,
|
|
45
45
|
email_verified: false,
|
|
46
|
-
status: "
|
|
46
|
+
status: "ACTIVE",
|
|
47
47
|
login_attempts: 0,
|
|
48
48
|
auth_providers: "email", // Track that this user registered with email/password
|
|
49
49
|
created_at: now,
|
|
@@ -29,7 +29,7 @@ export declare function GET(request: NextRequest): Promise<NextResponse<{
|
|
|
29
29
|
}[];
|
|
30
30
|
}>>;
|
|
31
31
|
/**
|
|
32
|
-
* PATCH - Update user (deactivate: set status to '
|
|
32
|
+
* PATCH - Update user (deactivate: set status to 'BLOCKED', etc.)
|
|
33
33
|
*/
|
|
34
34
|
export declare function PATCH(request: NextRequest): Promise<NextResponse<{
|
|
35
35
|
error: string;
|
|
@@ -67,7 +67,7 @@ export async function GET(request) {
|
|
|
67
67
|
name: user.name || null,
|
|
68
68
|
email_address: user.email_address,
|
|
69
69
|
email_verified: user.email_verified || false,
|
|
70
|
-
is_active: user.status === "
|
|
70
|
+
is_active: user.status === "ACTIVE", // Derived from status column
|
|
71
71
|
last_logon: user.last_logon || null,
|
|
72
72
|
created_at: user.created_at || null,
|
|
73
73
|
profile_picture_url: user.profile_picture_url || null,
|
|
@@ -91,7 +91,7 @@ export async function GET(request) {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
|
-
* PATCH - Update user (deactivate: set status to '
|
|
94
|
+
* PATCH - Update user (deactivate: set status to 'BLOCKED', etc.)
|
|
95
95
|
*/
|
|
96
96
|
export async function PATCH(request) {
|
|
97
97
|
const logger = create_app_logger();
|
|
@@ -109,7 +109,7 @@ export async function PATCH(request) {
|
|
|
109
109
|
const hazoConnect = get_hazo_connect_instance();
|
|
110
110
|
// Handle is_active if provided (maps to status column)
|
|
111
111
|
if (typeof is_active === "boolean") {
|
|
112
|
-
update_data.status = is_active ? "
|
|
112
|
+
update_data.status = is_active ? "ACTIVE" : "BLOCKED";
|
|
113
113
|
}
|
|
114
114
|
// Handle app_user_data if provided
|
|
115
115
|
if (app_user_data !== undefined) {
|