aa
This commit is contained in:
@@ -12,23 +12,8 @@ import (
|
|||||||
|
|
||||||
//刷新验证码 POST
|
//刷新验证码 POST
|
||||||
func RefreshCode(c *gin.Context) {
|
func RefreshCode(c *gin.Context) {
|
||||||
var (
|
|
||||||
err error
|
|
||||||
user = &struct {
|
|
||||||
Width int `json:"width" form:"width" binding:"required"`
|
|
||||||
Height int `json:"height" form:"height" binding:"required"`
|
|
||||||
}{}
|
|
||||||
)
|
|
||||||
if err = c.ShouldBind(&user); err != nil {
|
|
||||||
c.JSON(http.StatusOK, &CallBack{
|
|
||||||
Code: model.ErrCodeNormal,
|
|
||||||
Desc: err.Error(),
|
|
||||||
})
|
|
||||||
globals.SugarLogger.Debugf("End API :%s error:%v:", c.Request.URL, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
globals.SugarLogger.Debugf("RefreshCode, ip: %v", c.ClientIP())
|
globals.SugarLogger.Debugf("RefreshCode, ip: %v", c.ClientIP())
|
||||||
utils.Captcha(c, user.Width, user.Height, 4)
|
utils.Captcha(c, 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserParam struct {
|
type UserParam struct {
|
||||||
|
|||||||
@@ -51,8 +51,9 @@ func RandStringBytesWithNumber(n int) string {
|
|||||||
return string(b)
|
return string(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Captcha(c *gin.Context, w, h int, length ...int) {
|
func Captcha(c *gin.Context, length ...int) {
|
||||||
l := captcha.DefaultLen
|
l := captcha.DefaultLen
|
||||||
|
w, h := 107, 36
|
||||||
if len(length) == 1 {
|
if len(length) == 1 {
|
||||||
l = length[0]
|
l = length[0]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user