mirror of
				https://github.com/bufanyun/hotgo.git
				synced 2025-11-04 16:23:43 +08:00 
			
		
		
		
	@@ -7,18 +7,19 @@ package common
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
	"github.com/gogf/gf/v2/errors/gerror"
 | 
					 | 
				
			||||||
	"github.com/gogf/gf/v2/frame/g"
 | 
					 | 
				
			||||||
	"github.com/gogf/gf/v2/net/ghttp"
 | 
					 | 
				
			||||||
	"github.com/gogf/gf/v2/text/gstr"
 | 
					 | 
				
			||||||
	"github.com/gogf/gf/v2/util/gconv"
 | 
					 | 
				
			||||||
	"github.com/gogf/gf/v2/util/gmode"
 | 
					 | 
				
			||||||
	"hotgo/api/admin/common"
 | 
						"hotgo/api/admin/common"
 | 
				
			||||||
	"hotgo/internal/consts"
 | 
						"hotgo/internal/consts"
 | 
				
			||||||
	"hotgo/internal/library/captcha"
 | 
						"hotgo/internal/library/captcha"
 | 
				
			||||||
	"hotgo/internal/library/token"
 | 
						"hotgo/internal/library/token"
 | 
				
			||||||
	"hotgo/internal/service"
 | 
						"hotgo/internal/service"
 | 
				
			||||||
	"hotgo/utility/validate"
 | 
						"hotgo/utility/validate"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/gogf/gf/v2/errors/gerror"
 | 
				
			||||||
 | 
						"github.com/gogf/gf/v2/frame/g"
 | 
				
			||||||
 | 
						"github.com/gogf/gf/v2/net/ghttp"
 | 
				
			||||||
 | 
						"github.com/gogf/gf/v2/text/gstr"
 | 
				
			||||||
 | 
						"github.com/gogf/gf/v2/util/gconv"
 | 
				
			||||||
 | 
						"github.com/gogf/gf/v2/util/gmode"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var Site = cSite{}
 | 
					var Site = cSite{}
 | 
				
			||||||
@@ -102,7 +103,7 @@ func (c *cSite) AccountLogin(ctx context.Context, req *common.AccountLoginReq) (
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if !req.IsLock && login.CaptchaSwitch == 1 {
 | 
						if !req.IsLock && login.CaptchaSwitch == consts.StatusEnabled {
 | 
				
			||||||
		// 校验 验证码
 | 
							// 校验 验证码
 | 
				
			||||||
		if !captcha.Verify(req.Cid, req.Code) {
 | 
							if !captcha.Verify(req.Cid, req.Code) {
 | 
				
			||||||
			err = gerror.New("验证码错误")
 | 
								err = gerror.New("验证码错误")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,12 +7,16 @@ package captcha
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
 | 
						"image/color"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/gogf/gf/v2/frame/g"
 | 
						"github.com/gogf/gf/v2/frame/g"
 | 
				
			||||||
	"github.com/gogf/gf/v2/text/gstr"
 | 
						"github.com/gogf/gf/v2/text/gstr"
 | 
				
			||||||
	"github.com/mojocn/base64Captcha"
 | 
						"github.com/mojocn/base64Captcha"
 | 
				
			||||||
	"image/color"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// store 验证码存储方式
 | 
				
			||||||
 | 
					var store = base64Captcha.DefaultMemStore
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Generate 生成验证码
 | 
					// Generate 生成验证码
 | 
				
			||||||
func Generate(ctx context.Context) (id string, base64 string) {
 | 
					func Generate(ctx context.Context) (id string, base64 string) {
 | 
				
			||||||
	// 字符
 | 
						// 字符
 | 
				
			||||||
@@ -47,7 +51,7 @@ func Generate(ctx context.Context) (id string, base64 string) {
 | 
				
			|||||||
		Fonts: []string{"chromohv.ttf"},
 | 
							Fonts: []string{"chromohv.ttf"},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c := base64Captcha.NewCaptcha(driver.ConvertFonts(), base64Captcha.DefaultMemStore)
 | 
						c := base64Captcha.NewCaptcha(driver.ConvertFonts(), store)
 | 
				
			||||||
	id, base64, _, err := c.Generate()
 | 
						id, base64, _, err := c.Generate()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		g.Log().Errorf(ctx, "captcha.Generate err:%+v", err)
 | 
							g.Log().Errorf(ctx, "captcha.Generate err:%+v", err)
 | 
				
			||||||
@@ -60,6 +64,5 @@ func Verify(id, answer string) bool {
 | 
				
			|||||||
	if id == "" || answer == "" {
 | 
						if id == "" || answer == "" {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	c := base64Captcha.NewCaptcha(new(base64Captcha.DriverString), base64Captcha.DefaultMemStore)
 | 
						return store.Verify(id, gstr.ToLower(answer), true)
 | 
				
			||||||
	return c.Verify(id, gstr.ToLower(answer), true)
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -629,17 +629,7 @@ func (s *sAdminMember) List(ctx context.Context, in *adminin.MemberListInp) (lis
 | 
				
			|||||||
		mod = mod.WhereBetween(cols.CreatedAt, gtime.New(in.CreatedAt[0]), gtime.New(in.CreatedAt[1]))
 | 
							mod = mod.WhereBetween(cols.CreatedAt, gtime.New(in.CreatedAt[0]), gtime.New(in.CreatedAt[1]))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	totalCount, err = mod.Count()
 | 
						if err = mod.Hook(hook.MemberInfo).Page(in.Page, in.PerPage).OrderDesc(cols.Id).ScanAndCount(&list, &totalCount, true); err != nil {
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		err = gerror.Wrap(err, "获取用户数据行失败!")
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if totalCount == 0 {
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if err = mod.Hook(hook.MemberInfo).Page(in.Page, in.PerPage).OrderDesc(cols.Id).Scan(&list); err != nil {
 | 
					 | 
				
			||||||
		err = gerror.Wrap(err, "获取用户列表失败!")
 | 
							err = gerror.Wrap(err, "获取用户列表失败!")
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,6 +21,7 @@
 | 
				
			|||||||
        ref="actionRef"
 | 
					        ref="actionRef"
 | 
				
			||||||
        openChecked
 | 
					        openChecked
 | 
				
			||||||
        :columns="columns"
 | 
					        :columns="columns"
 | 
				
			||||||
 | 
					        :pagination="false"
 | 
				
			||||||
        :request="loadDataTable"
 | 
					        :request="loadDataTable"
 | 
				
			||||||
        :row-key="(row) => row.id"
 | 
					        :row-key="(row) => row.id"
 | 
				
			||||||
        :actionColumn="actionColumn"
 | 
					        :actionColumn="actionColumn"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user