Admin xem chi tiết thông tin user
Feature URL
Module
admin
Status
in-development
Priority
P1
Platforms
fe · be
AC progress
11 / 13
Last reviewed
2026-05-29
Mục tiêu
Cho phép admin xem đầy đủ thông tin một user để support, kiểm duyệt và đánh giá rủi ro trước khi thao tác ban/unban hoặc quản lý role. Detail này có thể chứa private fields phục vụ vận hành nhưng vẫn không trả password hash hoặc refresh token.
Phạm vi
Trong phạm vi (In scope):
- Admin mở detail user từ danh sách
/admin/users. - API
GET /api/v1/admin/users/{id}trả full admin projection. - Hiển thị identity/profile/status/roles/auth provider/referral/anti-fraud/quota/login timestamps.
- Không trả password, refresh token hoặc refresh token expiry.
- FE detail page/drawer hiển thị thông tin và CTA action phù hợp theo status/role.
Ngoài phạm vi (Out of scope):
- Chỉnh sửa hồ sơ user từ admin.
- Ban/unban user, xem feature
admin-user-ban-unban. - Gán/gỡ role, xem feature
admin-user-role-management. - Audit history dạng DB-backed timeline.
User Stories
- Là admin support, tôi muốn xem email/phone và trạng thái user để hỗ trợ đúng tài khoản.
- Là admin kiểm duyệt, tôi muốn xem role, signup IP/user-agent và referral để đánh giá rủi ro.
- Là admin vận hành, tôi muốn xem quota unlock và login timestamps để hiểu hành vi sử dụng tài khoản.
Luồng chức năng
sequenceDiagram
actor Admin
participant Web
participant BE
participant DB
Admin->>Web: Chọn một user trong danh sách
Web->>BE: GET /api/v1/admin/users/{id}
BE->>BE: Kiểm tra role admin
BE->>DB: Load user với roles
alt Không tìm thấy user
BE-->>Web: 404 Not Found
Web->>Admin: Báo user không tồn tại
else Thành công
BE-->>Web: AdminUserResponse
Web->>Admin: Render thông tin chi tiết + actions
endAcceptance Criteria
- AC-1: Backend có
GET /api/v1/admin/users/{id}, chỉ admin được gọi. - AC-2: Nếu user không tồn tại, API trả not found.
- AC-3: Backend load user bằng roles-aware loader để response có role codes.
- AC-4: Response là
AdminUserResponse. - AC-5: Response gồm profile/identity fields:
id,fullName,email,phone,avatarUrl,bio,province,ward. - AC-6: Response gồm lifecycle và role fields:
status,roles. - AC-7: Response gồm auth fields:
authProvider,providerId,emailVerified. - AC-8: Response gồm referral projection:
referralCode,referredBy {id, fullName, avatarUrl}nếu có. - AC-9: Response gồm anti-fraud và quota fields:
signupIp,signupUserAgent,unlockLimit,unlockUsed. - AC-10: Response gồm timestamps:
createdAt,updatedAt,lastLoginAt. - AC-11: API không trả
password,refreshToken,refreshTokenExpiresAt. - AC-12: FE cần detail page/drawer cho
/admin/users/{id}hoặc tương đương. - AC-13: FE constants cần trỏ đúng
GET /api/v1/admin/users/{id}.
Quy tắc nghiệp vụ
- Detail admin được phép hiển thị private fields vì đây là màn vận hành nội bộ.
- Authentication artifacts không bao giờ được trả qua API, kể cả cho admin.
- Referrer trong response là projection nhẹ; admin muốn xem sâu referrer thì mở detail user đó.
- Detail là nguồn dữ liệu để quyết định action, nhưng action mutation phải gọi endpoint riêng.
- FE phải tránh render action ban với user admin hoặc chính admin nếu backend đã biết rule này.
Dữ liệu & Trạng thái
Entity nghiệp vụ:
User: nguồn detail.Role: role membership của user.AdminUserResponse: full admin projection.AdminUserResponse.Referrer: projection người giới thiệu.
Trạng thái user-facing:
detail-loading— đang tải detail.detail-ready— có dữ liệu user.detail-not-found— user không tồn tại hoặc đã bị xoá.detail-error— lỗi tải detail.
Liên quan
- Phụ thuộc: admin-user-list-search
- Ảnh hưởng: admin-user-ban-unban, admin-user-role-management