From 4806025f89fa7330d70ad90fbfb6351af6a8dc09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sat, 25 Mar 2023 20:51:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E8=87=AA=E5=8A=A8=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E8=AF=81=E4=B9=A6=E5=92=8C=E6=89=B9=E9=87=8F=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E8=AF=81=E4=B9=A6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/models/ssl_cert_dao_test.go | 14 -------------- internal/rpc/services/service_server.go | 3 +++ internal/rpc/services/service_ssl_cert.go | 12 ++++++------ 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/internal/db/models/ssl_cert_dao_test.go b/internal/db/models/ssl_cert_dao_test.go index f41504b9..5e0f0756 100644 --- a/internal/db/models/ssl_cert_dao_test.go +++ b/internal/db/models/ssl_cert_dao_test.go @@ -238,17 +238,3 @@ func TestSSLCertDAO_Update_JSON(t *testing.T) { t.Log(cert) } } - -func TestSSLCertDAO_FindAllCertsMatchDomains(t *testing.T) { - dbs.NotifyReady() - - var tx *dbs.Tx - var dao = models.NewSSLCertDAO() - certs, err := dao.FindAllCertsMatchDomains(tx, 0, []string{"goedge.cn", "teaos.cn", "www.goedge.cn", "'hello\"'", "中文.com", "xn---1.com", "global.dl.goedge.cn"}) - if err != nil { - t.Fatal(err) - } - for _, cert := range certs { - t.Log("id:", cert.Id, "userId:", cert.UserId, "name:", cert.Name, "dnsNames:", cert.DecodeDNSNames(), "end:", timeutil.FormatTime("Y-m-d H:i:s", int64(cert.TimeEndAt))) - } -} diff --git a/internal/rpc/services/service_server.go b/internal/rpc/services/service_server.go index 9d3ca50f..97835907 100644 --- a/internal/rpc/services/service_server.go +++ b/internal/rpc/services/service_server.go @@ -899,6 +899,7 @@ func (this *ServerService) ListEnabledServersMatch(ctx context.Context, req *pb. Name: clusterName, }, ServerGroups: pbGroups, + UserId: int64(server.UserId), User: pbUser, BandwidthTime: server.BandwidthTime, BandwidthBytes: int64(server.BandwidthBytes), @@ -1046,6 +1047,7 @@ func (this *ServerService) FindEnabledServer(ctx context.Context, req *pb.FindEn Name: clusterName, }, ServerGroups: pbGroups, + UserId: int64(server.UserId), User: pbUser, }}, nil } @@ -1571,6 +1573,7 @@ func (this *ServerService) FindEnabledUserServerBasic(ctx context.Context, req * Description: server.Description, IsOn: server.IsOn, Type: server.Type, + UserId: int64(server.UserId), NodeCluster: &pb.NodeCluster{ Id: int64(server.ClusterId), Name: clusterName, diff --git a/internal/rpc/services/service_ssl_cert.go b/internal/rpc/services/service_ssl_cert.go index a8d6d7ab..ed97e6e6 100644 --- a/internal/rpc/services/service_ssl_cert.go +++ b/internal/rpc/services/service_ssl_cert.go @@ -180,10 +180,10 @@ func (this *SSLCertService) CountSSLCerts(ctx context.Context, req *pb.CountSSLC var tx = this.NullTx() - if userId > 0 { - userId = req.UserId - } else if adminId > 0 { + if adminId > 0 { userId = req.UserId + } else if userId <= 0 { + return nil, errors.New("invalid user") } count, err := models.SharedSSLCertDAO.CountCerts(tx, req.IsCA, req.IsAvailable, req.IsExpired, int64(req.ExpiringDays), req.Keyword, userId, req.Domains) @@ -202,10 +202,10 @@ func (this *SSLCertService) ListSSLCerts(ctx context.Context, req *pb.ListSSLCer return nil, err } - if userId > 0 { - userId = req.UserId - } else if adminId > 0 { + if adminId > 0 { userId = req.UserId + } else if userId <= 0 { + return nil, errors.New("invalid user") } var tx = this.NullTx()