mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-11-14 13:13:51 +08:00
gf2版本同步升级到v2.0.4,修复验证器兼容问题
This commit is contained in:
@@ -11,12 +11,10 @@ import (
|
||||
"github.com/gogf/gf/v2/os/gcache"
|
||||
)
|
||||
|
||||
type cache struct {
|
||||
}
|
||||
// 缓存
|
||||
var Cache = new(cache)
|
||||
|
||||
var (
|
||||
Cache = new(cache)
|
||||
)
|
||||
type cache struct{}
|
||||
|
||||
func (component *cache) New() *gcache.Cache {
|
||||
c := gcache.New()
|
||||
|
||||
@@ -13,13 +13,14 @@ import (
|
||||
"github.com/mojocn/base64Captcha"
|
||||
)
|
||||
|
||||
// 验证码
|
||||
var Captcha = new(captcha)
|
||||
|
||||
type captcha struct{}
|
||||
|
||||
//
|
||||
// @Title 获取字母数字混合验证码
|
||||
// @Description
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param ctx
|
||||
// @Return idKeyC
|
||||
@@ -27,27 +28,27 @@ type captcha struct{}
|
||||
//
|
||||
func (component *captcha) GetVerifyImgString(ctx context.Context) (idKeyC string, base64stringC string) {
|
||||
driver := &base64Captcha.DriverString{
|
||||
Height: 80,
|
||||
Width: 240,
|
||||
Height: 80,
|
||||
Width: 240,
|
||||
//NoiseCount: 50,
|
||||
//ShowLineOptions: 20,
|
||||
Length: 4,
|
||||
Source: "abcdefghjkmnpqrstuvwxyz23456789",
|
||||
Fonts: []string{"chromohv.ttf"},
|
||||
Length: 4,
|
||||
Source: "abcdefghjkmnpqrstuvwxyz23456789",
|
||||
Fonts: []string{"chromohv.ttf"},
|
||||
}
|
||||
driver = driver.ConvertFonts()
|
||||
store := base64Captcha.DefaultMemStore
|
||||
c := base64Captcha.NewCaptcha(driver, store)
|
||||
idKeyC, base64stringC, err := c.Generate()
|
||||
if err != nil {
|
||||
g.Log().Error(ctx,err)
|
||||
g.Log().Error(ctx, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 验证输入的验证码是否正确
|
||||
// @Description
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param id
|
||||
// @Param answer
|
||||
@@ -59,4 +60,4 @@ func (component *captcha) VerifyString(id, answer string) bool {
|
||||
c := base64Captcha.NewCaptcha(driver, store)
|
||||
answer = gstr.ToLower(answer)
|
||||
return c.Verify(id, answer, true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,11 @@ import (
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
type comContext struct{}
|
||||
|
||||
// 上下文
|
||||
var Context = new(comContext)
|
||||
|
||||
type comContext struct{}
|
||||
|
||||
//
|
||||
// @Title 初始化上下文对象指针到上下文对象中,以便后续的请求流程中可以修改
|
||||
// @Description
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// IP归属地
|
||||
var Ip = new(ip)
|
||||
|
||||
type ip struct{}
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// jwt鉴权
|
||||
type JWT struct{}
|
||||
|
||||
var Jwt = new(JWT)
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// 统一响应
|
||||
var Response = new(response)
|
||||
|
||||
type response struct{}
|
||||
|
||||
Reference in New Issue
Block a user