From 5d12397e29487511e255c43b66494019319c7725 Mon Sep 17 00:00:00 2001 From: lafay <2021211506@stu.hit.edu.cn> Date: Sun, 26 Apr 2026 19:42:10 +0800 Subject: [PATCH] fix(user): add VerificationStatusNone for users without verification Add VerificationStatusNone constant and update converter to return general identity with none status instead of empty strings when user has not applied for verification. --- internal/dto/user_converter.go | 6 ++++-- internal/model/user.go | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/dto/user_converter.go b/internal/dto/user_converter.go index 45a1473..3618ac6 100644 --- a/internal/dto/user_converter.go +++ b/internal/dto/user_converter.go @@ -12,12 +12,14 @@ func getAvatarOrDefault(user *model.User) string { return utils.GetAvatarOrDefault(user.Username, user.Nickname, user.Avatar) } -// publicVerificationFields 仅在认证通过时返回身份和状态,避免泄漏审核中/已拒绝等隐私信息 +// publicVerificationFields 返回认证信息: +// - approved 时返回真实身份和状态 +// - 其他状态统一返回 general + none,不暴露具体审核状态 func publicVerificationFields(user *model.User) (model.UserIdentity, model.VerificationStatus) { if user.VerificationStatus == model.VerificationStatusApproved { return user.Identity, user.VerificationStatus } - return "", "" + return model.UserIdentityGeneral, model.VerificationStatusNone } // ConvertUserToResponse 将User转换为UserResponse(公开信息,不包含敏感数据) diff --git a/internal/model/user.go b/internal/model/user.go index ac1561b..b465ad1 100644 --- a/internal/model/user.go +++ b/internal/model/user.go @@ -54,6 +54,7 @@ const ( VerificationStatusPending VerificationStatus = "pending" // 审核中 VerificationStatusApproved VerificationStatus = "approved" // 已通过 VerificationStatusRejected VerificationStatus = "rejected" // 已拒绝 + VerificationStatusNone VerificationStatus = "none" // 无认证(对外展示用) ) // User 用户实体