功能:完善登录安全与客服手动下单

This commit is contained in:
yml2213
2026-08-13 12:40:04 +08:00
parent aea65a2fd3
commit 8c47b961e1
10 changed files with 161 additions and 43 deletions
+18
View File
@@ -43,3 +43,21 @@ func (h *AuthHandler) Profile(c *gin.Context) {
}
response.OK(c, user)
}
type changePasswordReq struct {
CurrentPassword string `json:"current_password" binding:"required"`
NewPassword string `json:"new_password" binding:"required,min=8"`
}
func (h *AuthHandler) ChangePassword(c *gin.Context) {
var req changePasswordReq
if err := c.ShouldBindJSON(&req); err != nil {
response.BadRequest(c, "请填写当前密码和至少 8 位的新密码")
return
}
if err := h.svc.ChangePassword(middleware.GetUserID(c), req.CurrentPassword, req.NewPassword); err != nil {
response.BadRequest(c, err.Error())
return
}
response.OK(c, nil)
}