Ejemplo n.º 1
0
func (c *UserController) CreateRegisterCaptcha() {
	mail := c.GetString("mail")
	sessionId := c.CruSession.SessionID()
	var captcha string
	mailCaptchaKey := strings.Replace(constants.MAIL_CAPTCHA_KEY, "$sessionId", sessionId, 1)
	redis_util.Get(mailCaptchaKey, &captcha)
	beego.Debug("captcha", captcha)
	if len(captcha) == 0 {
		captcha = utils.RandomIntCaptcha(6)
		redis_util.Set(mailCaptchaKey, captcha, 60*2)
	}
	content := fmt.Sprintf(services.MAIL_CAPTCHA_TEMPLATE, captcha, captcha)
	services.SendHtmlMail("threeperson(www.threeperson.com)注册验证码", content, []string{mail})
	c.JsonSuccess(60)

}
Ejemplo n.º 2
0
func TestCaptchaCreate(t *testing.T) {
	for i := 0; i < 10; i++ {
		fmt.Println(utils.RandomIntCaptcha(6))
	}
}