修复公开密码重置查询泄露超级管理员身份的问题
This commit is contained in:
1 parent
df0be7f555
commit
51ab0a6d0c
5 files changed
+142
-2
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/auth"
|
||||
)
|
||||
|
||||
type publicPasswordResetGuidance struct {
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Action string `json:"action"`
|
||||
}
|
||||
|
||||
// showPasswordResetGuidance 仅验证输入格式,不查询账户,也不创建重置会话。
|
||||
// 公开路由必须使用此处理器,不能绑定历史的账户分类处理器。
|
||||
func (s *Server) showPasswordResetGuidance(c *gin.Context) {
|
||||
c.Header("Cache-Control", "no-store")
|
||||
var request passwordResetResolveRequest
|
||||
if err := bindJSON(c, &request, passwordResetResolveBodyLimit); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "账户信息格式无效"})
|
||||
return
|
||||
}
|
||||
if _, err := auth.NormalizeIdentifier(request.Identifier); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "请输入有效的用户名或绑定邮箱"})
|
||||
return
|
||||
}
|
||||
|
||||
s.configMu.RLock()
|
||||
ready := s.config.SetupReady
|
||||
s.configMu.RUnlock()
|
||||
if !ready {
|
||||
c.JSON(http.StatusConflict, gin.H{"error": "Scert 尚未完成初始化,暂不能处理密码重置"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, publicPasswordResetGuidance{
|
||||
Title: "密码重置",
|
||||
Description: "请联系系统管理员协助处理密码重置。为保护账户安全,此页面不确认账户是否存在或所属角色。",
|
||||
Action: "contact_administrator",
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user