feat(auth): 新增密码登录注册与改密功能并加固安全

- 后端:新增密码登录/注册/重置/改密接口,users 表新增 password_hash 字段
- 安全加固:注册改为冲突即失败防止"注册即改密",登录用户不存在统一返回密码错误并计失败次数防枚举,改密需校验旧密码,清理登录失败计数中的死代码
- 前端:登录页重构为"登录/注册"两个 tab,登录内可切换密码/短信方式,默认密码登录
- 个人中心新增修改密码入口(PC 弹窗 + 移动端 popup),PC 个人资料页移除买家/卖家服务面板
This commit is contained in:
yml2213
2026-07-02 19:02:49 +08:00
parent 3701ae36ab
commit 1ba7c1dea1
13 changed files with 1043 additions and 456 deletions
+4
View File
@@ -371,12 +371,16 @@ func New(cfg config.Config, deps Dependencies, logger *zap.Logger) *gin.Engine {
authRoutes.GET("/captcha", authHandler.Captcha)
authRoutes.POST("/sms/send", authHandler.SendSMS)
authRoutes.POST("/sms/login", authHandler.Login)
authRoutes.POST("/password/login", authHandler.PasswordLogin)
authRoutes.POST("/password/register", authHandler.Register)
authRoutes.POST("/password/reset", authHandler.ResetPassword)
authRoutes.POST("/refresh", authHandler.Refresh)
authRoutes.POST("/logout", authHandler.Logout)
}
api.GET("/me", requireAuth, userHandler.Me)
api.PUT("/me", requireAuth, userHandler.UpdateMe)
api.PUT("/password", requireAuth, authHandler.SetPassword)
listingRoutes := api.Group("/listings")
{