feat(auth): 接入 DCAuth v2 登录并完善成员管理
- 登录链路改为用户名 + 密码 + 短信验证码 + DCAuth v2 设备签名 - 迁移 014:新增 login_sms_codes / user_devices / device_challenges 与 users.phone - 新增 /api/dcauth/authorize 与 challenge 状态轮询;旧密码登录仅放行未绑定手机号的账号 - 成员管理支持手机号绑定、设备重置、账号改名、昵称与重置密码 - 移除最后一个商户关系时软删除账号,释放用户名、手机号并撤销设备绑定
This commit is contained in:
@@ -104,3 +104,34 @@ func (h *UserHandler) DeleteMerchantAccount(c *gin.Context) {
|
||||
}
|
||||
response.OK(c, nil)
|
||||
}
|
||||
|
||||
type bindUserPhoneReq struct {
|
||||
Phone string `json:"phone" binding:"required"`
|
||||
}
|
||||
|
||||
// BindPlatformUserPhone 管理员为用户绑定/修改登录手机号。
|
||||
func (h *UserHandler) BindPlatformUserPhone(c *gin.Context) {
|
||||
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||
var req bindUserPhoneReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
response.BadRequest(c, "请输入手机号")
|
||||
return
|
||||
}
|
||||
user, err := h.svc.BindUserPhone(uint(id), req.Phone, middleware.GetUserID(c))
|
||||
if err != nil {
|
||||
writeServiceError(c, err, "手机号绑定失败")
|
||||
return
|
||||
}
|
||||
response.OK(c, user)
|
||||
}
|
||||
|
||||
// ResetPlatformUserDevice 管理员重置用户绑定的 DCAuth 设备。
|
||||
func (h *UserHandler) ResetPlatformUserDevice(c *gin.Context) {
|
||||
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||
reset, err := h.svc.ResetUserDevice(uint(id), middleware.GetUserID(c))
|
||||
if err != nil {
|
||||
writeServiceError(c, err, "设备重置失败")
|
||||
return
|
||||
}
|
||||
response.OK(c, gin.H{"reset": reset})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user