From 75bb07184f56aab0eaf80bd36afe2535cf1acee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sun, 3 Oct 2021 14:43:29 +0800 Subject: [PATCH] =?UTF-8?q?ACME=E4=BD=BF=E7=94=A8EAB=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E7=9A=84=E8=B4=A6=E5=8F=B7=E5=8F=AA=E8=83=BD=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../servers/certs/acme/users/createPopup.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/internal/web/actions/default/servers/certs/acme/users/createPopup.go b/internal/web/actions/default/servers/certs/acme/users/createPopup.go index 5cf902b9..4b474dc3 100644 --- a/internal/web/actions/default/servers/certs/acme/users/createPopup.go +++ b/internal/web/actions/default/servers/certs/acme/users/createPopup.go @@ -61,8 +61,23 @@ func (this *CreatePopupAction) RunPost(params struct { if providerResp.AcmeProvider == nil { this.Fail("找不到要选择的证书") } - if providerResp.AcmeProvider.RequireEAB && params.AccountId <= 0 { - this.Fail("此服务商要求必须选择或创建服务商账号") + if providerResp.AcmeProvider.RequireEAB { + if params.AccountId <= 0 { + this.Fail("此服务商要求必须选择或创建服务商账号") + } + + // 同一个账号只能有一个用户 + countResp, err := this.RPC().ACMEUserRPC(). + CountACMEUsers(this.AdminContext(), &pb.CountAcmeUsersRequest{ + AcmeProviderAccountId: params.AccountId, + }) + if err != nil { + this.ErrorPage(err) + return + } + if countResp.Count > 0 { + this.Fail("此服务商账号已被别的用户使用,请换成别的账号") + } } createResp, err := this.RPC().ACMEUserRPC().CreateACMEUser(this.AdminContext(), &pb.CreateACMEUserRequest{