优化后端鉴权与日志安全

This commit is contained in:
yml2213
2026-05-26 08:21:11 +08:00
parent 851d1d1efc
commit dea3023825
35 changed files with 402 additions and 185 deletions
@@ -6,6 +6,7 @@ type AdminUserRow = {
password_hash: string
role: string
status: string
session_version: number
created_at: string
updated_at: string
}
@@ -21,7 +22,7 @@ type AdminUserCreateInput = {
type AdminUserPatch = Partial<Pick<
AdminUserRow,
'username' | 'password_hash' | 'role' | 'status' | 'updated_at'
'username' | 'password_hash' | 'role' | 'status' | 'session_version' | 'updated_at'
>>
type AdminUserListInput = {
@@ -66,9 +67,10 @@ export async function createAdminUser(input: AdminUserCreateInput): Promise<Admi
password_hash,
role,
status,
session_version,
created_at,
updated_at
) VALUES ($1, $2, $3, $4, $5, $6)
) VALUES ($1, $2, $3, $4, $5, $6, $7)
RETURNING id
`,
[
@@ -76,6 +78,7 @@ export async function createAdminUser(input: AdminUserCreateInput): Promise<Admi
input.passwordHash,
input.role,
input.status,
1,
input.createdAt,
input.updatedAt,
],
@@ -102,8 +105,9 @@ export async function updateAdminUser(
password_hash = $2,
role = $3,
status = $4,
updated_at = $5
WHERE id = $6
session_version = $5,
updated_at = $6
WHERE id = $7
RETURNING id
`,
[
@@ -111,6 +115,7 @@ export async function updateAdminUser(
next.password_hash,
next.role,
next.status,
Number(next.session_version || 1),
next.updated_at,
Number(userId),
],
@@ -61,7 +61,7 @@ type FulfillmentProfileUpsertInput = {
updatedAt: string
}
type FulfillmentProfileRequirementInput = {
export type FulfillmentProfileRequirementInput = {
roleKey: string
credentialType: string
quantityPerUnit?: number | string