From a450fe3eef21eae62c1e32de637e2696ba03e459 Mon Sep 17 00:00:00 2001 From: lanrenwo Date: Thu, 2 Jun 2022 20:50:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtest=E6=9C=AA=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/dbdata/group.go | 14 +++++++++----- server/dbdata/user.go | 5 ++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/server/dbdata/group.go b/server/dbdata/group.go index d39d476..831c194 100644 --- a/server/dbdata/group.go +++ b/server/dbdata/group.go @@ -154,19 +154,23 @@ func SetGroup(g *Group) error { if err != nil { return errors.New("排除域名有误:" + err.Error()) } - // 处理认证类型 + // 处理认证方式的逻辑 + defAuth := map[string]interface{}{ + "type": "local", + } + if len(g.Auth) == 0 { + g.Auth = defAuth + } switch g.Auth["type"] { case "local": - g.Auth = map[string]interface{}{ - "type": g.Auth["type"], - } + g.Auth = defAuth case "radius": err = checkRadiusData(g.Auth) if err != nil { return err } default: - return errors.New("未知的认证类型") + return errors.New("#" + fmt.Sprintf("%s", g.Auth["type"]) + "#未知的认证类型") } g.UpdatedAt = time.Now() diff --git a/server/dbdata/user.go b/server/dbdata/user.go index c513e63..5f634f7 100644 --- a/server/dbdata/user.go +++ b/server/dbdata/user.go @@ -8,7 +8,6 @@ import ( "sync" "time" - "github.com/bjdgyc/anylink/base" "github.com/bjdgyc/anylink/pkg/utils" "github.com/xlzd/gotp" "layeh.com/radius" @@ -79,12 +78,12 @@ func CheckUser(name, pwd, group string) error { if err != nil { return fmt.Errorf("%s %s", name, "No用户组") } + // 初始化Auth if len(groupData.Auth) == 0 { groupData.Auth["type"] = "local" } - base.Debug(name + " auth type: " + fmt.Sprintf("%s", groupData.Auth["type"])) switch groupData.Auth["type"] { - case "local": + case "", "local": return checkLocalUser(name, pwd, group) case "radius": radisConf := AuthRadius{}