func admin_banUser(ctx *goku.HttpContext) goku.ActionResulter { var err error var errs string var ok = false var userId, status int64 userId, err = strconv.ParseInt(ctx.Get("id"), 10, 64) if err == nil { status, err = strconv.ParseInt(ctx.Get("status"), 10, 64) } if err == nil { _, err = models.User_Update(userId, map[string]interface{}{"Status": status}) } if err != nil { errs = err.Error() } else { ok = true } r := map[string]interface{}{ "success": ok, "errors": errs, } return ctx.Json(r) }
}). Post("recover", func(ctx *goku.HttpContext) goku.ActionResulter { user, ur, r := userRecoverPreProcess(ctx) if r != nil { return r } f := createResetPasswordForm() f.FillByRequest(ctx.Request) errorMsgs := make([]string, 0) if f.Valid() { m := f.CleanValues() if m["new-pwd"] == m["new-pwd2"] { saveMap := map[string]interface{}{"pwd": utils.PasswordHash(m["new-pwd"].(string))} _, err := models.User_Update(user.Id, saveMap) if err != nil { errorMsgs = append(errorMsgs, golink.ERROR_DATABASE) goku.Logger().Errorln(err) } else { ur.Active = false ur.RecoveryTime = time.Now().UTC() ur.Update() } } else { errorMsgs = append(errorMsgs, "两次输入的新密码不一致") } } else { errs := f.Errors() for _, v := range errs { errorMsgs = append(errorMsgs, v[0]+": "+v[1])