修复:管理员默认商户与账户设置
This commit is contained in:
@@ -49,6 +49,13 @@ type changePasswordReq struct {
|
||||
NewPassword string `json:"new_password" binding:"required,min=8"`
|
||||
}
|
||||
|
||||
type updateCurrentAccountReq struct {
|
||||
CurrentPassword string `json:"current_password" binding:"required"`
|
||||
Username string `json:"username" binding:"required"`
|
||||
Nickname string `json:"nickname"`
|
||||
NewPassword string `json:"new_password" binding:"omitempty,min=8"`
|
||||
}
|
||||
|
||||
func (h *AuthHandler) ChangePassword(c *gin.Context) {
|
||||
var req changePasswordReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
@@ -61,3 +68,22 @@ func (h *AuthHandler) ChangePassword(c *gin.Context) {
|
||||
}
|
||||
response.OK(c, nil)
|
||||
}
|
||||
|
||||
func (h *AuthHandler) UpdateCurrentAccount(c *gin.Context) {
|
||||
var req updateCurrentAccountReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
response.BadRequest(c, "请填写用户名和当前密码;新密码至少 8 位")
|
||||
return
|
||||
}
|
||||
user, err := h.svc.UpdateCurrentAccount(middleware.GetUserID(c), service.UpdateCurrentAccountInput{
|
||||
CurrentPassword: req.CurrentPassword,
|
||||
Username: req.Username,
|
||||
Nickname: req.Nickname,
|
||||
NewPassword: req.NewPassword,
|
||||
})
|
||||
if err != nil {
|
||||
response.BadRequest(c, err.Error())
|
||||
return
|
||||
}
|
||||
response.OK(c, user)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user