[CLAUDE] Infra: fix lock-demo-user prod NO-OP — union 20 UAT-matrix email + DemoUserPassword 12 ký tự (S58)
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 4m43s

Run #381 cicd phát hiện LockDemoSampleUsersAsync NO-OP trên prod: 14 email
named-person là population Dev-only. Root cause sâu: DemoUserPassword 11 ký tự
< prod RequiredLength=12 → CreateAsync silent-fail mọi startup từ trước tới giờ
(luôn cả nv.cao/nv.truong IT pool — root cause helpdesk inert S56 — và 5 real
staff thiếu account).

Fix (anh chốt 3 quyết định qua AskUserQuestion):
- Union 20 email UAT-matrix prod thật (act/equ/fin/hra/pm/qs × nv/pp/tp + bod.1/2,
  tạo tay 05-13) vào lock list — exact-email only, KHÔNG pattern (binh.le@ là
  người thật sát scheme demo).
- DemoUserPassword User@123456 → User@1234567 (12 ký tự, thỏa policy prod) →
  startup tới trên prod sẽ TẠO named-person (rồi lock ngay cùng startup) +
  nv.cao/nv.truong ACTIVE (helpdesk sống lại) + 5 real staff.
- GIỮ ACTIVE: nv.test (creds cicd smoke-verify) + chuong.phan@solution.com.vn
  (typo domain nhưng có thể login thật anh Chương — xác nhận rồi dọn sau).

Trade-off deadline 15:00: ship trước, test-specialist viết guard test sau
(test-after justify — list-data fix, logic lock không đổi).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-06-11 12:56:45 +07:00
parent dd117b749c
commit 5998163642

View File

@ -1538,27 +1538,50 @@ public static class DbInitializer
// - Nếu user đã có → verify dept + position + roles, fix nếu drift
// - Try-catch per-user → 1 fail không abort 12 còn lại
// - Log chi tiết success/fixed/created/failed counts
// Default password: User@123456 (warn log để rotate prod).
private const string DemoUserPassword = "User@123456";
// Default password: User@1234567 (warn log để rotate prod).
// [S58 2026-06-11] 11→12 ký tự: prod set Identity:Password:RequiredLength=12
// (appsettings.Production.json) → CreateAsync silent-fail MỌI user dùng const này
// trên prod từ trước tới giờ (named-person sample + nv.cao/nv.truong IT pool +
// 5 real staff — root cause "helpdesk inert" S56). User Dev cũ giữ pass cũ
// (const chỉ áp dụng lúc CREATE user mới, không đổi pass existing).
private const string DemoUserPassword = "User@1234567";
// [S57bis 2026-06-11] Khóa 14/16 demo sample user — sếp yêu cầu "clear dữ liệu cũ",
// [S57bis 2026-06-11] Khóa demo sample user — sếp yêu cầu "clear dữ liệu cũ",
// anh chốt scope: CHỈ khóa user demo (GIỮ phiếu/HĐ/NCC/dự án demo). Ungated idempotent
// (mirror SeedRealMasterDataAsync philosophy): chạy mọi startup → khóa BỀN kể cả ai
// re-activate nhầm. GIỮ ACTIVE có chủ đích:
// re-activate nhầm. Email không tồn tại trong DB → skip vô hại.
// [S58 2026-06-11] +20 email UAT-matrix `{dept}.{nv|pp|tp}@` + `bod.{1,2}@` = population
// prod THẬT (tạo TAY qua admin UI 2026-05-13 — chưa từng nằm trong seed). 14 email
// named-person = population Dev (prod không có — DemoUserPassword cũ 11 ký tự fail
// RequiredLength=12, đã fix). KHÔNG khóa theo pattern/regex: binh.le@/binh.lethanh@
// là người thật nằm sát scheme demo — CHỈ exact-email list.
// GIỮ ACTIVE có chủ đích (KHÔNG đưa vào list):
// - nv.cao + nv.truong : IT helpdesk round-robin pool (S52 P11-D) — khóa nốt SAU KHI
// anh gán ≥1 user thật vào Phòng CNTT (ops-pending S56), tránh helpdesk chết hẳn.
// - catalog.manager : account chức năng quản danh mục dùng chung (Plan CA S29).
// - nv.test : creds cicd-monitor smoke-verify prod sau deploy (anh chốt S58).
// - chuong.phan@solution.com.vn (domain thiếu 's', không trong seed): typo-dup của bản
// @solutions nhưng có thể là login thật anh Chương đang dùng — giữ, xác nhận rồi dọn sau.
// Muốn mở lại 1 user có chủ đích → gỡ email khỏi list này + admin re-activate.
private static async Task LockDemoSampleUsersAsync(
UserManager<User> userManager, ILogger logger)
{
string[] emails =
[
// Population Dev — named-person sample seed (16 trừ nv.cao/nv.truong)
"bod.huynh@solutions.com.vn", "bod.le@solutions.com.vn", "bod.tran@solutions.com.vn",
"pm.nguyen@solutions.com.vn", "pm.le@solutions.com.vn",
"ccm.tran@solutions.com.vn", "pro.pham@solutions.com.vn", "fin.do@solutions.com.vn",
"act.vu@solutions.com.vn", "equ.bui@solutions.com.vn", "hra.dang@solutions.com.vn",
"qs.hoang@solutions.com.vn", "qs.ngo@solutions.com.vn", "nv.dinh@solutions.com.vn",
// Population prod — UAT-matrix tạo tay 2026-05-13 (S58)
"act.nv@solutions.com.vn", "act.pp@solutions.com.vn", "act.tp@solutions.com.vn",
"bod.1@solutions.com.vn", "bod.2@solutions.com.vn",
"equ.nv@solutions.com.vn", "equ.pp@solutions.com.vn", "equ.tp@solutions.com.vn",
"fin.nv@solutions.com.vn", "fin.pp@solutions.com.vn", "fin.tp@solutions.com.vn",
"hra.nv@solutions.com.vn", "hra.pp@solutions.com.vn", "hra.tp@solutions.com.vn",
"pm.nv@solutions.com.vn", "pm.pp@solutions.com.vn", "pm.tp@solutions.com.vn",
"qs.nv@solutions.com.vn", "qs.pp@solutions.com.vn", "qs.tp@solutions.com.vn",
];
var locked = 0;