MCPcopy Index your code
hub / github.com/aiprodcoder/MIXAPI / ResetPassword

Function ResetPassword

controller/misc.go:272–302  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

270}
271
272func ResetPassword(c *gin.Context) {
273 var req PasswordResetRequest
274 err := json.NewDecoder(c.Request.Body).Decode(&req)
275 if req.Email == "" || req.Token == "" {
276 c.JSON(http.StatusOK, gin.H{
277 "success": false,
278 "message": "无效的参数",
279 })
280 return
281 }
282 if !common.VerifyCodeWithKey(req.Email, req.Token, common.PasswordResetPurpose) {
283 c.JSON(http.StatusOK, gin.H{
284 "success": false,
285 "message": "重置链接非法或已过期",
286 })
287 return
288 }
289 password := common.GenerateVerificationCode(12)
290 err = model.ResetUserPasswordByEmail(req.Email, password)
291 if err != nil {
292 common.ApiError(c, err)
293 return
294 }
295 common.DeleteKey(req.Email, common.PasswordResetPurpose)
296 c.JSON(http.StatusOK, gin.H{
297 "success": true,
298 "message": "",
299 "data": password,
300 })
301 return
302}

Callers

nothing calls this directly

Calls 5

VerifyCodeWithKeyFunction · 0.92
GenerateVerificationCodeFunction · 0.92
ResetUserPasswordByEmailFunction · 0.92
ApiErrorFunction · 0.92
DeleteKeyFunction · 0.92

Tested by

no test coverage detected