MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / ChangePassword

Method ChangePassword

internal/api/user.go:178–201  ·  view source on GitHub ↗

ChangePassword 修改密码

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

176
177// ChangePassword 修改密码
178func (uh *UserHandler) ChangePassword(ctx *gin.Context) {
179 var req req.ChangeReq
180 if err := ctx.ShouldBindJSON(&req); err != nil {
181 apiresponse.ErrorWithMessage(ctx, "无效的请求参数")
182 return
183 }
184
185 if req.NewPassword != req.ConfirmPassword {
186 apiresponse.ErrorWithMessage(ctx, UserPasswordMismatchError)
187 return
188 }
189
190 err := uh.svc.ChangePassword(ctx.Request.Context(), req.Username, req.Password, req.NewPassword, req.ConfirmPassword)
191 if err != nil {
192 if errors.Is(err, service.ErrInvalidUserOrPassword) {
193 apiresponse.ErrorWithMessage(ctx, UserPasswordChangeFailure)
194 return
195 }
196 apiresponse.ErrorWithMessage(ctx, UserPasswordChangeFailure)
197 return
198 }
199
200 apiresponse.Success(ctx)
201}
202
203// SendEmail 发送邮件验证码
204func (uh *UserHandler) SendEmail(ctx *gin.Context) {

Callers

nothing calls this directly

Calls 3

ErrorWithMessageFunction · 0.92
SuccessFunction · 0.92
ChangePasswordMethod · 0.65

Tested by

no test coverage detected