From e90c2aae6cc46dfee72c7be8ae84e8319d67cb85 Mon Sep 17 00:00:00 2001 From: lanrenwo Date: Tue, 5 Jul 2022 18:11:55 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E9=87=8C=E6=A0=87=E7=AD=BE=E9=A1=B5=E7=9A=84=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/dbdata/userauth_ldap.go | 3 +-- web/src/pages/group/List.vue | 28 +++++++++++++++++++++++----- web/src/pages/user/Policy.vue | 25 ++++++++++++++++++++++--- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/server/dbdata/userauth_ldap.go b/server/dbdata/userauth_ldap.go index 868e764..f6c6995 100644 --- a/server/dbdata/userauth_ldap.go +++ b/server/dbdata/userauth_ldap.go @@ -45,7 +45,7 @@ func (auth AuthLdap) checkData(authData map[string]interface{}) error { return errors.New("LDAP的用户查询密码不能为空") } if auth.BaseDn == "" || !ValidateDN(auth.BaseDn) { - return errors.New("LDAP的BaseName填写有误") + return errors.New("LDAP的BaseDN填写有误") } if auth.SearchAttr == "" { return errors.New("LDAP的搜索属性不能为空") @@ -117,7 +117,6 @@ func (auth AuthLdap) checkUser(name, pwd string, g *Group) error { return fmt.Errorf("LDAP发现 %s 用户,存在多个账号", name) } userDN := sr.Entries[0].DN - fmt.Println(userDN) err = l.Bind(userDN, pwd) if err != nil { return fmt.Errorf("%s LDAP 登入失败,请检查登入的账号或密码 %s", name, err.Error()) diff --git a/web/src/pages/group/List.vue b/web/src/pages/group/List.vue index 714416f..1014d6e 100644 --- a/web/src/pages/group/List.vue +++ b/web/src/pages/group/List.vue @@ -168,10 +168,11 @@ title="用户组" :visible.sync="user_edit_dialog" width="750px" + @close='closeDialog' center> - + @@ -359,7 +360,7 @@ 保存 - 取消 + 取消 @@ -473,10 +474,9 @@ export default { console.log(error); }); }, - handleEdit(row) { + handleEdit(row) { !this.$refs['ruleForm'] || this.$refs['ruleForm'].resetFields(); - console.log(row) - this.activeTab = "general" + console.log(row) this.user_edit_dialog = true if (!row) { this.setAuthData(row) @@ -561,6 +561,24 @@ export default { }, authTypeChange() { this.$refs['ruleForm'].clearValidate(); + }, + beforeTabLeave() { + var isSwitch = true + if (! this.user_edit_dialog) { + return isSwitch; + } + this.$refs['ruleForm'].validate((valid) => { + if (!valid) { + this.$message.error("错误:您有必填项没有填写。") + isSwitch = false; + return false; + } + }); + return isSwitch; + }, + closeDialog() { + this.user_edit_dialog = false; + this.activeTab = "general"; } }, } diff --git a/web/src/pages/user/Policy.vue b/web/src/pages/user/Policy.vue index b2a852e..848a38e 100644 --- a/web/src/pages/user/Policy.vue +++ b/web/src/pages/user/Policy.vue @@ -136,10 +136,11 @@ :visible.sync="user_edit_dialog" width="750px" top="50px" + @close='closeDialog' center> - + @@ -283,7 +284,7 @@ export default { re_upper_limit : 0, }, rules: { - name: [ + username: [ {required: true, message: '请输入用户名', trigger: 'blur'}, {max: 30, message: '长度小于 30 个字符', trigger: 'blur'} ], @@ -398,7 +399,25 @@ export default { } else { this.$set(this.readMore, id, true); } - }, + }, + beforeTabLeave() { + var isSwitch = true + if (! this.user_edit_dialog) { + return isSwitch; + } + this.$refs['ruleForm'].validate((valid) => { + if (!valid) { + this.$message.error("错误:您有必填项没有填写。") + isSwitch = false; + return false; + } + }); + return isSwitch; + }, + closeDialog() { + this.user_edit_dialog = false; + this.activeTab = "general"; + }, }, } From b0569b33ccd275a862f1d32e2b9844418ca989b8 Mon Sep 17 00:00:00 2001 From: lanrenwo Date: Wed, 6 Jul 2022 09:16:35 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0go.mod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/go.mod | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/go.mod b/server/go.mod index 4f3d552..55df247 100644 --- a/server/go.mod +++ b/server/go.mod @@ -4,6 +4,8 @@ go 1.16 require ( github.com/StackExchange/wmi v1.2.1 // indirect + github.com/go-ldap/ldap v3.0.3+incompatible // indirect + github.com/go-ldap/ldap/v3 v3.4.3 // indirect github.com/go-sql-driver/mysql v1.6.0 github.com/golang-jwt/jwt/v4 v4.0.0 github.com/google/gopacket v1.1.19 @@ -22,9 +24,10 @@ require ( github.com/tklauser/go-sysconf v0.3.7 // indirect github.com/xhit/go-simple-mail/v2 v2.10.0 github.com/xlzd/gotp v0.0.0-20181030022105-c8557ba2c119 - golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 - golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d + golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 + golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac + gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect layeh.com/radius v0.0.0-20210819152912-ad72663a72ab xorm.io/xorm v1.2.2 ) From 5c413673832af24f99dfa672fd942abc7bd24e9f Mon Sep 17 00:00:00 2001 From: lanrenwo Date: Wed, 6 Jul 2022 13:41:09 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=89=A7=E8=A1=8C=20con.Close()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/dbdata/userauth_ldap.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/dbdata/userauth_ldap.go b/server/dbdata/userauth_ldap.go index f6c6995..1e6a3f0 100644 --- a/server/dbdata/userauth_ldap.go +++ b/server/dbdata/userauth_ldap.go @@ -74,10 +74,11 @@ func (auth AuthLdap) checkUser(name, pwd string, g *Group) error { return fmt.Errorf("%s %s", name, "LDAP Unmarshal出现错误") } // 检测服务器和端口的可用性 - _, err = net.DialTimeout("tcp", auth.Addr, 3*time.Second) + con, err := net.DialTimeout("tcp", auth.Addr, 3*time.Second) if err != nil { return fmt.Errorf("%s %s", name, "LDAP服务器连接异常, 请检测服务器和端口") } + defer con.Close() // 连接LDAP l, err := ldap.Dial("tcp", auth.Addr) if err != nil {