// create form once html func (this *BaseController) FormOnceCreate(args ...bool) { var value string var creat bool creat = len(args) > 0 && args[0] if !creat { if v, ok := this.GetSession("form_once").(string); ok && v != "" { value = v } else { creat = true } } if creat { value = utils.GetRandomString(10) this.SetSession("form_once", value) } this.Data["once_token"] = value this.Data["once_html"] = template.HTML(`<input type="hidden" name="_once" value="` + value + `">`) }
// return a user salt token func GetUserSalt() string { return utils.GetRandomString(10) }