增加注册强制邀请码开关、微信内登录自动获取openid开关

This commit is contained in:
孟帅 2023-05-15 10:17:04 +08:00
parent a1ca9bfafc
commit 6187fedd4e
26 changed files with 157 additions and 96 deletions

View File

@ -3,7 +3,6 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package admin
import (
@ -103,7 +102,7 @@ func (c *cRole) UpdatePermissions(ctx context.Context, req *role.UpdatePermissio
}
// DataScopeSelect 获取数据权限选项
func (c *cRole) DataScopeSelect(ctx context.Context, req *role.DataScopeSelectReq) (res *role.DataScopeSelectRes, err error) {
func (c *cRole) DataScopeSelect(ctx context.Context, _ *role.DataScopeSelectReq) (res *role.DataScopeSelectRes, err error) {
data := service.AdminRole().DataScopeSelect(ctx)
res = new(role.DataScopeSelectRes)
res.List = data

View File

@ -3,7 +3,6 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package common
import (
@ -43,7 +42,7 @@ func (c *cEms) SendTest(ctx context.Context, req *common.SendTestEmailReq) (res
}
// SendBindEms 发送换绑邮件
func (c *cSms) SendBindEms(ctx context.Context, req *common.SendBindEmsReq) (res *common.SendBindEmsRes, err error) {
func (c *cSms) SendBindEms(ctx context.Context, _ *common.SendBindEmsReq) (res *common.SendBindEmsRes, err error) {
var (
memberId = contexts.GetUserId(ctx)
models *entity.AdminMember

View File

@ -36,7 +36,6 @@ func (c *cSite) Config(ctx context.Context, _ *common.SiteConfigReq) (res *commo
Version: consts.VersionApp,
WsAddr: c.getWsAddr(ctx, request),
Domain: c.getDomain(ctx, request),
//InviteUrl: "http://192.168.1.27:8001/#/login?scope=register&inviteCode=",
}
return
}

View File

@ -3,7 +3,6 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package sys
import (
@ -46,7 +45,7 @@ func (c *cConfig) UpdateConfig(ctx context.Context, req *config.UpdateReq) (res
}
// TypeSelect 数据类型选项
func (c *cConfig) TypeSelect(ctx context.Context, req *config.TypeSelectReq) (res config.TypeSelectRes, err error) {
func (c *cConfig) TypeSelect(_ context.Context, _ *config.TypeSelectReq) (res config.TypeSelectRes, err error) {
for _, v := range consts.ConfigTypes {
res = append(res, form.Select{
Value: v,
@ -58,8 +57,8 @@ func (c *cConfig) TypeSelect(ctx context.Context, req *config.TypeSelectReq) (re
}
// GetCash 获取指定分组的配置
func (c *cConfig) GetCash(ctx context.Context, req *config.GetCashReq) (res *config.GetCashRes, err error) {
func (c *cConfig) GetCash(ctx context.Context, _ *config.GetCashReq) (res *config.GetCashRes, err error) {
res = new(config.GetCashRes)
res.GetConfigModel, err = service.SysConfig().GetConfigByGroup(ctx, sysin.GetConfigInp{Group: "cash"})
return
}
}

View File

@ -3,7 +3,6 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package sys
import (
@ -99,7 +98,7 @@ func (c *cCronGroup) Status(ctx context.Context, req *cron.GroupStatusReq) (res
}
// Select 选项
func (c *cCronGroup) Select(ctx context.Context, req *cron.GroupSelectReq) (res *cron.GroupSelectRes, err error) {
func (c *cCronGroup) Select(ctx context.Context, _ *cron.GroupSelectReq) (res *cron.GroupSelectRes, err error) {
data, err := service.SysCronGroup().Select(ctx, sysin.CronGroupSelectInp{})
if err != nil {
return

View File

@ -3,7 +3,6 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package sys
import (
@ -21,7 +20,7 @@ var (
type cDictType struct{}
// Tree 树
func (c *cDictType) Tree(ctx context.Context, req *dict.TypeTreeReq) (res *dict.TypeTreeRes, err error) {
func (c *cDictType) Tree(ctx context.Context, _ *dict.TypeTreeReq) (res *dict.TypeTreeRes, err error) {
res = new(dict.TypeTreeRes)
res.List, err = service.SysDictType().Tree(ctx)
return

View File

@ -3,7 +3,6 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package sys
import (
@ -22,7 +21,7 @@ var Log = sLog{}
type sLog struct{}
// Clear 清空日志
func (c *sLog) Clear(ctx context.Context, req *log.ClearReq) (res *log.ClearRes, err error) {
func (c *sLog) Clear(ctx context.Context, _ *log.ClearReq) (res *log.ClearRes, err error) {
err = gerror.New("暂时考虑到安全问题,请到数据库清空")
return
}

View File

@ -3,7 +3,6 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package member
import (
@ -18,7 +17,7 @@ var (
type cMember struct{}
func (c *cMember) GetIdByCode(ctx context.Context, req *member.GetIdByCodeReq) (res *member.GetIdByCodeRes, err error) {
func (c *cMember) GetIdByCode(ctx context.Context, _ *member.GetIdByCodeReq) (res *member.GetIdByCodeRes, err error) {
g.RequestFromCtx(ctx).Response.Writeln("Hello World api member!")
return
}

View File

@ -20,7 +20,7 @@ var (
type cNotify struct{}
// AliPay 支付宝回调
func (c *cNotify) AliPay(ctx context.Context, req *pay.NotifyAliPayReq) (res *pay.NotifyAliPayRes, err error) {
func (c *cNotify) AliPay(ctx context.Context, _ *pay.NotifyAliPayReq) (res *pay.NotifyAliPayRes, err error) {
_, err = service.Pay().Notify(ctx, payin.PayNotifyInp{PayType: consts.PayTypeAliPay})
if err != nil {
return nil, err
@ -30,7 +30,7 @@ func (c *cNotify) AliPay(ctx context.Context, req *pay.NotifyAliPayReq) (res *pa
}
// WxPay 微信支付回调
func (c *cNotify) WxPay(ctx context.Context, req *pay.NotifyWxPayReq) (res *pay.NotifyWxPayRes, err error) {
func (c *cNotify) WxPay(ctx context.Context, _ *pay.NotifyWxPayReq) (res *pay.NotifyWxPayRes, err error) {
_, err = service.Pay().Notify(ctx, payin.PayNotifyInp{PayType: consts.PayTypeWxPay})
if err != nil {
return nil, err
@ -42,7 +42,7 @@ func (c *cNotify) WxPay(ctx context.Context, req *pay.NotifyWxPayReq) (res *pay.
}
// QQPay QQ支付回调
func (c *cNotify) QQPay(ctx context.Context, req *pay.NotifyQQPayReq) (res *pay.NotifyQQPayRes, err error) {
func (c *cNotify) QQPay(ctx context.Context, _ *pay.NotifyQQPayReq) (res *pay.NotifyQQPayRes, err error) {
_, err = service.Pay().Notify(ctx, payin.PayNotifyInp{PayType: consts.PayTypeQQPay})
if err != nil {
return nil, err

View File

@ -3,7 +3,6 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package user
import (
@ -18,7 +17,7 @@ var (
type cHello struct{}
func (c *cHello) Hello(ctx context.Context, req *user.HelloReq) (res *user.HelloRes, err error) {
func (c *cHello) Hello(ctx context.Context, _ *user.HelloReq) (res *user.HelloRes, err error) {
g.RequestFromCtx(ctx).Response.Writeln("Hello World api member!")
return
}

View File

@ -3,7 +3,6 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package base
import (
@ -20,7 +19,7 @@ var Site = cSite{}
type cSite struct{}
func (a *cSite) Index(ctx context.Context, req *base.SiteIndexReq) (res *base.SiteIndexRes, err error) {
func (a *cSite) Index(ctx context.Context, _ *base.SiteIndexReq) (res *base.SiteIndexRes, err error) {
service.View().Render(ctx, model.View{Data: g.Map{
"name": "HotGo",
"version": consts.VersionApp,

View File

@ -437,6 +437,11 @@ func (s *sAdminMember) Edit(ctx context.Context, in adminin.MemberEditInp) (err
return
}
config, err := service.SysConfig().GetLogin(ctx)
if err != nil {
return
}
// 修改
if in.Id > 0 {
if s.VerifySuperId(ctx, in.Id) {
@ -462,17 +467,20 @@ func (s *sAdminMember) Edit(ctx context.Context, in adminin.MemberEditInp) (err
return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
if _, err = mod.Where("id", in.Id).Data(in).Update(); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return
}
// 更新岗位
return dao.AdminMemberPost.UpdatePostIds(ctx, in.Id, in.PostIds)
if err = dao.AdminMemberPost.UpdatePostIds(ctx, in.Id, in.PostIds); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
}
return
})
}
// 新增用户时的额外属性
var data adminin.MemberAddInp
data.MemberEditInp = in
data.Salt = grand.S(6)
data.InviteCode = grand.S(12)
data.PasswordHash = gmd5.MustEncryptString(data.Password + data.Salt)
@ -484,14 +492,24 @@ func (s *sAdminMember) Edit(ctx context.Context, in adminin.MemberEditInp) (err
return
}
// 默认头像
if in.Avatar == "" {
in.Avatar = config.Avatar
}
data.MemberEditInp = in
return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
id, err := dao.AdminMember.Ctx(ctx).Data(data).InsertAndGetId()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return
}
// 更新岗位
return dao.AdminMemberPost.UpdatePostIds(ctx, id, in.PostIds)
if err = dao.AdminMemberPost.UpdatePostIds(ctx, id, in.PostIds); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
}
return
})
}

View File

@ -32,8 +32,17 @@ func init() {
// Register 账号注册
func (s *sAdminSite) Register(ctx context.Context, in adminin.RegisterInp) (err error) {
var data adminin.MemberAddInp
config, err := service.SysConfig().GetLogin(ctx)
if err != nil {
return
}
if config.ForceInvite == 1 && in.InviteCode == "" {
err = gerror.New("请填写邀请码")
return
}
var data adminin.MemberAddInp
// 默认上级
data.Pid = 1
@ -52,11 +61,6 @@ func (s *sAdminSite) Register(ctx context.Context, in adminin.RegisterInp) (err
data.Pid = pmb.Id
}
config, err := service.SysConfig().GetLogin(ctx)
if err != nil {
return
}
if config.RegisterSwitch != 1 {
err = gerror.New("管理员未开放注册")
return
@ -123,10 +127,15 @@ func (s *sAdminSite) Register(ctx context.Context, in adminin.RegisterInp) (err
return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
id, err := dao.AdminMember.Ctx(ctx).Data(data).InsertAndGetId()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return
}
return dao.AdminMemberPost.UpdatePostIds(ctx, id, config.PostIds)
// 更新岗位
if err = dao.AdminMemberPost.UpdatePostIds(ctx, id, config.PostIds); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
}
return
})
}
@ -252,6 +261,7 @@ func (s *sAdminSite) handleLogin(ctx context.Context, mb *entity.AdminMember) (r
// 更新登录信息
if _, err = dao.AdminMember.Ctx(ctx).Data(update).Where(do.AdminMember{Id: mb.Id}).Update(); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return
}

View File

@ -162,11 +162,13 @@ type LoginConfig struct {
RegisterSwitch int `json:"loginRegisterSwitch"`
CaptchaSwitch int `json:"loginCaptchaSwitch"`
Avatar string `json:"loginAvatar"`
Protocol string `json:"loginProtocol"`
Policy string `json:"loginPolicy"`
RoleId int64 `json:"loginRoleId"`
DeptId int64 `json:"loginDeptId"`
PostIds []int64 `json:"loginPostIds"`
Protocol string `json:"loginProtocol"`
Policy string `json:"loginPolicy"`
AutoOpenId int `json:"loginAutoOpenId"`
ForceInvite int `json:"loginForceInvite"`
}
///////////// 以下是本地配置

View File

@ -1,13 +1,14 @@
-- phpMyAdmin SQL Dump
-- version 5.2.1
-- version 4.9.0.1
-- https://www.phpmyadmin.net/
--
-- 主机 localhost
-- 生成日期 2023-05-14 08:51:30
-- 服务器版本 5.7.41
-- PHP 版本 7.3.33
-- 主机 localhost:3306
-- 生成日期 2023-05-15 10:04:47
-- 服务器版本 5.7.38-log
-- PHP 版本 5.6.40
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
@ -72,8 +73,8 @@ CREATE TABLE `hg_addon_hgexample_table` (
--
INSERT INTO `hg_addon_hgexample_table` (`id`, `category_id`, `flag`, `title`, `description`, `content`, `image`, `images`, `attachfile`, `attachfiles`, `map`, `star`, `price`, `views`, `activity_at`, `start_at`, `end_at`, `switch`, `sort`, `avatar`, `sex`, `qq`, `email`, `mobile`, `hobby`, `channel`, `city_id`, `pid`, `level`, `tree`, `remark`, `status`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 1, '[1, 2]', '测试标题', '描述', '<p>这是内容............</p>', 'http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqamvhlq4w3ki6bl.webp', '[\"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqap5l9brk2lkavu.jpg\", \"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqaqua7fw8ukbbp5.jpg\"]', 'http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqaup19k9oznyixz.doc', '[\"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqawg96ba4cuezvv.xlsx\", \"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqaup19k9oznyixz.doc\"]', '[{\"key\": \"qwe\", \"value\": \"123\"}, {\"key\": \"asd\", \"value\": \"456\"}]', 3.0, 88.00, 10, '2022-12-23', '2022-12-01 00:00:00', '2022-12-31 23:59:59', 1, 20, '', 15, '133814250', '133814250@qq.com', '15303830571', '[3, 2, 1]', 1, 140406, 0, 1, '', '备注!', 1, 1, 3, '2022-12-15 19:30:14', '2023-04-28 16:46:17', NULL),
(2, 0, '[1]', '测试2', '描述', '<h2><strong>不知道写点啥</strong></h2><p><br></p><p><img src=\"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqbknawlkgdttuxl.png\"></p>', 'http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqbmxmtaq06gbnqa.jpeg', '[\"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqborf529kf4cxbm.jpeg\"]', 'http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqawg96ba4cuezvv.xlsx', '[\"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqaup19k9oznyixz.doc\"]', '{}', 2.5, 10.00, 0, '2023-02-18', NULL, NULL, 2, 30, '', 0, '', '1561561@qq.com', '15303830571', '[2, 1]', 3, 140214, 0, 1, '', '', 1, 1, 1, '2023-02-06 14:17:11', '2023-02-23 13:59:01', NULL);
(1, 1, '[1, 2]', '测试标题', '描述', '<p>这是内容............</p>', 'http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqamvhlq4w3ki6bl.webp', '[\"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqap5l9brk2lkavu.jpg\", \"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqaqua7fw8ukbbp5.jpg\"]', 'http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqaup19k9oznyixz.doc', '[\"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqawg96ba4cuezvv.xlsx\", \"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqaup19k9oznyixz.doc\"]', '[{\"key\": \"qwe\", \"value\": \"123\"}, {\"key\": \"asd\", \"value\": \"456\"}]', '3.0', '88.00', 10, '2022-12-23', '2022-12-01 00:00:00', '2022-12-31 23:59:59', 1, 20, '', 15, '133814250', '133814250@qq.com', '15303830571', '[3, 2, 1]', 1, 140406, 0, 1, '', '备注!', 1, 1, 3, '2022-12-15 19:30:14', '2023-04-28 16:46:17', NULL),
(2, 0, '[1]', '测试2', '描述', '<h2><strong>不知道写点啥</strong></h2><p><br></p><p><img src=\"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqbknawlkgdttuxl.png\"></p>', 'http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqbmxmtaq06gbnqa.jpeg', '[\"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqborf529kf4cxbm.jpeg\"]', 'http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqawg96ba4cuezvv.xlsx', '[\"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdqaup19k9oznyixz.doc\"]', '{}', '2.5', '10.00', 0, '2023-02-18', NULL, NULL, 2, 30, '', 0, '', '1561561@qq.com', '15303830571', '[2, 1]', 3, 140214, 0, 1, '', '', 1, 1, 1, '2023-02-06 14:17:11', '2023-02-23 13:59:01', NULL);
-- --------------------------------------------------------
@ -198,9 +199,9 @@ CREATE TABLE `hg_admin_member` (
--
INSERT INTO `hg_admin_member` (`id`, `dept_id`, `role_id`, `real_name`, `username`, `password_hash`, `salt`, `password_reset_token`, `integral`, `balance`, `avatar`, `sex`, `qq`, `email`, `mobile`, `birthday`, `city_id`, `address`, `pid`, `level`, `tree`, `invite_code`, `cash`, `last_active_at`, `remark`, `status`, `created_at`, `updated_at`) VALUES
(1, 100, 1, '孟帅', 'admin', 'a7c588fffeb2c1d99b29879d7fe97c78', '6541561', '', 89.00, 99391.78, 'http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdq8er9nfkchdopav.png', 1, '133814250', '133814250@qq.com', '15303830571', '2016-04-16', 410172, '莲花街001号', 0, 1, '', '111', '{\"name\": \"孟帅\", \"account\": \"15303830571\", \"payeeCode\": \"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdq8mqal5isvcb58g.jpg\"}', '2023-05-14 16:44:27', NULL, 1, '2021-02-12 17:59:45', '2023-05-14 16:44:27'),
(3, 100, 2, '测试账号', 'test', 'a7c588fffeb2c1d99b29879d7fe97c78', '6541561', '', 0.00, 4.00, 'http://alioss.qvnidaye.com//images/2021/03/12/image_1615529198_vMK4kwq2.jpg', 1, '', 'c@qq.cc', '15303888888', '2016-04-13', 371100, '大潮街道666号', 1, 2, 'tr_1 ', '222', NULL, '2023-05-14 12:29:15', '', 1, '2022-02-11 17:59:45', '2023-05-14 12:29:15'),
(8, 101, 200, 'ameng', 'ameng', '382df3b083a27886edb94e669a857c33', 'hfuUEb', '', 11.00, 3.22, '', 1, '', '', '', NULL, 0, '', 1, 2, 'tr_1 ', '333', NULL, '2023-05-14 12:25:24', '', 1, '2023-02-03 17:34:31', '2023-05-14 12:25:24');
(1, 100, 1, '孟帅', 'admin', 'a7c588fffeb2c1d99b29879d7fe97c78', '6541561', '', '89.00', '99391.78', 'http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdq8er9nfkchdopav.png', 1, '133814250', '133814250@qq.com', '15303830571', '2016-04-16', 410172, '莲花街001号', 0, 1, '', '111', '{\"name\": \"孟帅\", \"account\": \"15303830571\", \"payeeCode\": \"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdq8mqal5isvcb58g.jpg\"}', '2023-05-15 09:59:29', NULL, 1, '2021-02-12 17:59:45', '2023-05-15 09:59:29'),
(3, 100, 2, '测试账号', 'test', 'a7c588fffeb2c1d99b29879d7fe97c78', '6541561', '', '0.00', '4.00', 'http://alioss.qvnidaye.com//images/2021/03/12/image_1615529198_vMK4kwq2.jpg', 1, '', 'c@qq.cc', '15303888888', '2016-04-13', 371100, '大潮街道666号', 1, 2, 'tr_1 ', '222', NULL, '2023-05-14 12:29:15', '', 1, '2022-02-11 17:59:45', '2023-05-14 12:29:15'),
(8, 101, 200, 'ameng', 'ameng', '382df3b083a27886edb94e669a857c33', 'hfuUEb', '', '11.00', '3.22', '', 1, '', '', '', NULL, 0, '', 1, 2, 'tr_1 ', '333', NULL, '2023-05-14 12:25:24', '', 1, '2023-02-03 17:34:31', '2023-05-14 12:25:24');
-- --------------------------------------------------------
@ -1367,14 +1368,16 @@ INSERT INTO `hg_sys_config` (`id`, `group`, `name`, `type`, `key`, `value`, `def
(109, 'wechat', '开放平台AppSecret', 'string', 'openPlatformAppSecret', '', '', 1050, '请填写微信开放平台平台后台的AppSecret', 1, 1, '2021-01-30 13:27:43', '2023-04-30 22:26:12'),
(110, 'wechat', '开放平台EncodingAESKey', 'string', 'openPlatformEncodingAESKey', '', '', 1060, '与开放平台接入设置值一致必须为英文或者数字长度为43个字符. 请妥善保管,EncodingAESKey 泄露将可能被窃取或篡改平台的操作数据', 1, 1, '2021-01-30 13:27:43', '2023-04-30 22:26:12'),
(111, 'wechat', '开放平台token', 'string', 'openPlatformToken', '', '', 1070, '', 1, 1, '2021-01-30 13:27:43', '2023-04-30 22:26:12'),
(112, 'login', '注册开关', 'int', 'loginRegisterSwitch', '1', '1', 1100, '', 1, 1, '2021-09-29 23:51:21', '2023-05-14 16:35:46'),
(113, 'login', '验证码开关', 'int', 'loginCaptchaSwitch', '1', '1', 1110, '', 1, 1, '2021-09-29 23:51:21', '2023-05-14 16:35:46'),
(114, 'login', '用户协议', 'string', 'loginProtocol', '<p><span style=\"color: rgb(31, 34, 37);\">用户协议..</span></p>', '', 1120, '', 1, 1, '2021-09-29 23:51:21', '2023-05-14 16:35:46'),
(115, 'login', '隐私权政策', 'string', 'loginPolicy', '<p><span style=\"color: rgb(31, 34, 37);\">隐私权政策..</span></p>', '', 1130, '', 1, 1, '2021-09-29 23:51:21', '2023-05-14 16:35:46'),
(116, 'login', '默认注册角色', 'int64', 'loginRoleId', '202', '', 1140, '', 1, 1, '2021-09-29 23:51:21', '2023-05-14 16:35:46'),
(117, 'login', '默认注册部门', 'int64', 'loginDeptId', '112', '', 1150, '', 1, 1, '2021-09-29 23:51:21', '2023-05-14 16:35:46'),
(118, 'login', '默认注册岗位', '[]int64', 'loginPostIds', '[4,6]', '', 1160, '', 1, 1, '2021-09-29 23:51:21', '2023-05-14 16:35:46'),
(119, 'login', '默认注册头像', 'string', 'loginAvatar', 'http://localhost:8000/attachment/2023-05-14/csltf747yrr4gd4kc5.png', '', 1170, '', 1, 1, '2021-09-29 23:51:21', '2023-05-14 16:35:46');
(112, 'login', '注册开关', 'int', 'loginRegisterSwitch', '1', '1', 1100, '', 1, 1, '2021-09-29 23:51:21', '2023-05-15 09:46:09'),
(113, 'login', '验证码开关', 'int', 'loginCaptchaSwitch', '1', '1', 1110, '', 1, 1, '2021-09-29 23:51:21', '2023-05-15 09:46:09'),
(114, 'login', '用户协议', 'string', 'loginProtocol', '<p><span style=\"color: rgb(31, 34, 37);\">用户协议..</span></p>', '', 1120, '', 1, 1, '2021-09-29 23:51:21', '2023-05-15 09:46:09'),
(115, 'login', '隐私权政策', 'string', 'loginPolicy', '<p><span style=\"color: rgb(31, 34, 37);\">隐私权政策..</span></p>', '', 1130, '', 1, 1, '2021-09-29 23:51:21', '2023-05-15 09:46:09'),
(116, 'login', '默认注册角色', 'int64', 'loginRoleId', '202', '', 1140, '', 1, 1, '2021-09-29 23:51:21', '2023-05-15 09:46:09'),
(117, 'login', '默认注册部门', 'int64', 'loginDeptId', '112', '', 1150, '', 1, 1, '2021-09-29 23:51:21', '2023-05-15 09:46:09'),
(118, 'login', '默认注册岗位', '[]int64', 'loginPostIds', '[6]', '', 1160, '', 1, 1, '2021-09-29 23:51:21', '2023-05-15 09:46:09'),
(119, 'login', '默认注册头像', 'string', 'loginAvatar', 'http://localhost:8000/attachment/2023-05-14/csltf747yrr4gd4kc5.png', '', 1170, '', 1, 1, '2021-09-29 23:51:21', '2023-05-15 09:46:09'),
(120, 'login', '强制邀请', 'int', 'loginForceInvite', '2', '1', 1190, '', 1, 1, '2021-09-29 23:51:21', '2023-05-15 09:46:09'),
(121, 'login', '自动获取openId', 'int', 'loginAutoOpenId', '2', '1', 1195, '', 1, 1, '2021-09-29 23:51:21', '2023-05-15 09:46:09');
-- --------------------------------------------------------
@ -5941,7 +5944,7 @@ ALTER TABLE `hg_sys_blacklist`
-- 使用表AUTO_INCREMENT `hg_sys_config`
--
ALTER TABLE `hg_sys_config`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '配置ID', AUTO_INCREMENT=120;
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '配置ID', AUTO_INCREMENT=122;
--
-- 使用表AUTO_INCREMENT `hg_sys_cron`

View File

@ -3,7 +3,6 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package file
import (
@ -11,7 +10,7 @@ import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/text/gstr"
"io/ioutil"
"io"
"path"
)
@ -139,7 +138,7 @@ func UploadFileByte(file *ghttp.UploadFile) (b []byte, err error) {
if err != nil {
return
}
all, err := ioutil.ReadAll(open)
all, err := io.ReadAll(open)
if err != nil {
return
}

View File

@ -1,13 +1,13 @@
import type { RouteRecordRaw } from 'vue-router';
import { isNavigationFailure, Router } from 'vue-router';
import { UserInfoState, useUserStoreWidthOut } from '@/store/modules/user';
import { useUserStoreWidthOut } from '@/store/modules/user';
import { useAsyncRouteStoreWidthOut } from '@/store/modules/asyncRoute';
import { ACCESS_TOKEN } from '@/store/mutation-types';
import { storage } from '@/utils/Storage';
import { PageEnum } from '@/enums/pageEnum';
import { ErrorPageRoute } from '@/router/base';
import { isWechatBrowser } from '@/utils/is';
import { jump } from '@/utils/http/axios';
import { getNowUrl } from '@/utils/urlUtils';
const LOGIN_PATH = PageEnum.BASE_LOGIN;
const whitePathList = [LOGIN_PATH]; // no redirect whitelist
@ -64,21 +64,20 @@ export function createRouterGuards(router: Router) {
const redirect = decodeURIComponent(redirectPath);
const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect };
const userInfo = await userStore.GetInfo();
await userStore.LoadLoginConfig();
// 如果是微信访问,则记录本次登录的openid
if (isWechatBrowser() && (userInfo as UserInfoState).openId === '') {
// 否允许获取微信openid
if (userStore.allowWxOpenId()) {
let path = nextData.path;
if (path === LOGIN_PATH) {
path = PageEnum.BASE_HOME_REDIRECT;
}
const w = window.location;
const URI = w.protocol + '//' + w.host + w.pathname + '#' + path;
const URI = getNowUrl() + '#' + path;
jump('/wechat/authorize', { type: 'openId', syncRedirect: URI });
return;
}
await userStore.LoadLoginConfig();
await userStore.GetConfig();
const routes = await asyncRouteStore.generateRoutes(userInfo);

View File

@ -17,6 +17,7 @@ import {
logout,
mobileLogin,
} from '@/api/system/user';
import { isWechatBrowser } from '@/utils/is';
const Storage = createStorage({ storage: localStorage });
export interface UserInfoState {
@ -59,6 +60,7 @@ export interface ConfigState {
export interface LoginConfigState {
loginRegisterSwitch: number;
loginCaptchaSwitch: number;
loginAutoOpenId: number;
loginProtocol: string;
loginPolicy: string;
}
@ -218,6 +220,18 @@ export const useUserStore = defineStore({
});
});
},
// 是否允许获取微信openid
allowWxOpenId(): boolean {
if (!isWechatBrowser()) {
return false;
}
if (this.loginConfig?.loginAutoOpenId !== 1) {
return false;
}
return this.info?.openId === '';
},
// 登出
async logout() {
try {

View File

@ -41,3 +41,11 @@ export function getFileExt(fileName: string) {
}
return fileName.substring(fileName.lastIndexOf('.') + 1);
}
/**
* 访url
*/
export function getNowUrl(): string {
const w = window.location;
return w.protocol + '//' + w.host + w.pathname;
}

View File

@ -18,7 +18,11 @@
</n-icon>
</a>
</div>
<div class="flex-initial" style="margin-left: auto" v-if="userStore.loginConfig?.loginRegisterSwitch === 1">
<div
class="flex-initial"
style="margin-left: auto"
v-if="userStore.loginConfig?.loginRegisterSwitch === 1"
>
<a @click="updateActiveModule(moduleKey)">{{ tag }}</a>
</div>
</div>
@ -27,9 +31,8 @@
<script lang="ts" setup>
import { LogoWechat, LogoTiktok } from '@vicons/ionicons5';
import { useUserStore } from '@/store/modules/user';
import {useMessage} from "naive-ui";
import { useMessage } from 'naive-ui';
const userStore = useUserStore();

View File

@ -48,8 +48,6 @@
}
}
// ...
.justify-between {
justify-content: space-between;
}

View File

@ -110,7 +110,7 @@
<n-button :text="true" @click="handleResetPassword">忘记密码</n-button>
</div>
<n-button type="primary" size="large" :block="true" :loading="loading" @click="handleLogin">
确定
登录
</n-button>
<FormOther moduleKey="register" tag="注册账号" @updateActiveModule="updateActiveModule" />

View File

@ -1,12 +1,8 @@
<template>
<div>
<n-checkbox v-model:checked="checked" class="text-14px">我已阅读并接受</n-checkbox>
<n-button :text="true" type="primary" @click="handleClickProtocol" class="text-13px"
>用户协议</n-button
>
<n-button :text="true" type="primary" @click="handleClickPolicy" class="text-13px"
>隐私权政策</n-button
>
<n-button :text="true" type="primary" @click="handleClickProtocol">用户协议</n-button>
<n-button :text="true" type="primary" @click="handleClickPolicy">隐私权政策</n-button>
</div>
</template>
@ -41,6 +37,7 @@
function handleClickProtocol() {
emit('click-protocol');
}
function handleClickPolicy() {
emit('click-policy');
}

View File

@ -263,6 +263,7 @@
modalTitle.value = '用户协议';
modalContent.value = userStore.loginConfig?.loginProtocol as string;
}
function handleClickPolicy() {
showModal.value = true;
modalTitle.value = '隐私权政策';

View File

@ -229,7 +229,7 @@
<script lang="ts" setup>
import { h, reactive, ref } from 'vue';
import { SelectOption, TreeSelectOption, useDialog, useMessage } from 'naive-ui';
import { useDialog, useMessage } from 'naive-ui';
import { ActionItem, BasicTable, TableAction } from '@/components/Table';
import { BasicForm } from '@/components/Form/index';
import { Delete, Edit, List, Status, ResetPwd } from '@/api/org/user';
@ -245,9 +245,9 @@
import AddIntegral from './addIntegral.vue';
import { addNewState, addState, options, register, defaultState } from './model';
import { usePermission } from '@/hooks/web/usePermission';
import { useRouter } from 'vue-router';
import { useUserStore } from '@/store/modules/user';
import { LoginRoute } from '@/router';
import { getNowUrl } from '@/utils/urlUtils';
interface Props {
type?: string;
@ -266,7 +266,6 @@
};
const { hasPermission } = usePermission();
const router = useRouter();
const userStore = useUserStore();
const showIntegralModal = ref(false);
const showBalanceModal = ref(false);
@ -489,24 +488,15 @@
});
}
function handleUpdateDeptValue(
value: string | number | Array<string | number> | null,
_option: TreeSelectOption | null | Array<TreeSelectOption | null>
) {
function handleUpdateDeptValue(value) {
formParams.value.deptId = Number(value);
}
function handleUpdateRoleValue(
value: string | number | Array<string | number> | null,
_option: SelectOption | null | Array<SelectOption | null>
) {
function handleUpdateRoleValue(value) {
formParams.value.roleId = Number(value);
}
function handleUpdatePostValue(
value: string | number | Array<string | number> | null,
_option: SelectOption | null | Array<SelectOption | null>
) {
function handleUpdatePostValue(value) {
formParams.value.postIds = value;
}
@ -529,8 +519,7 @@
}
function handleInviteQR(code: string) {
const w = window.location;
const domain = w.protocol + '//' + w.host + w.pathname + '#';
const domain = getNowUrl() + '#';
qrParams.value.qrUrl = domain + LoginRoute.path + '?scope=register&inviteCode=' + code;
showQrModal.value = true;
}

View File

@ -2,6 +2,7 @@
<div>
<n-spin :show="show" description="请稍候...">
<n-form :label-width="100" :model="formValue" :rules="rules" ref="formRef">
<n-divider title-placement="left">开关配置</n-divider>
<n-form-item label="登录验证码开关" path="loginCaptchaSwitch">
<n-radio-group v-model:value="formValue.loginCaptchaSwitch" name="loginCaptchaSwitch">
<n-space>
@ -20,6 +21,31 @@
</n-radio-group>
</n-form-item>
<n-form-item label="强制邀请" path="loginForceInvite">
<n-radio-group v-model:value="formValue.loginForceInvite" name="loginForceInvite">
<n-space>
<n-radio :value="1">开启</n-radio>
<n-radio :value="2">关闭</n-radio>
</n-space>
</n-radio-group>
<template #feedback>
用户通过注册页面发起注册时是否必须填写邀请信息用于上下级关系绑定</template
>
</n-form-item>
<n-form-item label="自动获取openId" path="loginAutoOpenId">
<n-radio-group v-model:value="formValue.loginAutoOpenId" name="loginAutoOpenId">
<n-space>
<n-radio :value="1">开启</n-radio>
<n-radio :value="2">关闭</n-radio>
</n-space>
</n-radio-group>
<template #feedback>
在微信内登录后台时自动获取当前登录人的openid如开启需要配置微信公众号参数</template
>
</n-form-item>
<n-divider title-placement="left">注册默认信息配置</n-divider>
<n-form-item label="默认注册头像" path="loginAvatar">
<UploadImage :maxNumber="1" v-model:value="formValue.loginAvatar" />
</n-form-item>
@ -46,6 +72,7 @@
<n-select v-model:value="formValue.loginPostIds" multiple :options="options.post" />
</n-form-item>
<n-divider title-placement="left">协议配置</n-divider>
<n-form-item label="用户协议" path="loginProtocol">
<Editor
style="height: 320px"
@ -84,8 +111,10 @@
const formRef: any = ref(null);
const message = useMessage();
const formValue = ref({
loginRegisterSwitch: true,
loginCaptchaSwitch: true,
loginRegisterSwitch: 1,
loginCaptchaSwitch: 1,
loginForceInvite: 2,
loginAutoOpenId: 2,
loginAvatar: '',
loginProtocol: '',
loginPolicy: '',
@ -152,6 +181,7 @@
}
onMounted(async () => {
show.value = true;
await loadOptions();
load();
});