// Reset send a mail asking user to confirm reset password func (u *UsersController) Reset(ctx *gin.Context) { var userJSON userResetJSON ctx.Bind(&userJSON) var userIn models.User userIn.Username = strings.TrimSpace(userJSON.Username) userIn.Email = strings.TrimSpace(userJSON.Email) callback := strings.TrimSpace(userJSON.Callback) if len(userIn.Username) < 3 || len(userIn.Email) < 7 { err := fmt.Errorf("Invalid username (%s) or email (%s)", userIn.Username, userIn.Email) AbortWithReturnError(ctx, http.StatusInternalServerError, err) return } tokenVerify, err := userIn.AskReset() if err != nil { log.Errorf("Error while AskReset %s", err) ctx.AbortWithError(http.StatusInternalServerError, err) return } go utils.SendAskResetEmail(userIn.Username, userIn.Email, tokenVerify, callback) ctx.JSON(http.StatusCreated, gin.H{"info": "please check your mail to validate your account"}) }