From e53a88e4ddb0f661f9dfe10f6dd7fab3dbc009ad Mon Sep 17 00:00:00 2001 From: v-me-50 Date: Mon, 18 Aug 2025 15:49:26 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=94=9F=E6=88=90=E6=96=B0=E7=9A=84acme=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E6=97=B6=E6=9C=89=E6=A6=82=E7=8E=87=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E6=89=80=E6=9C=89=E8=B4=A6=E5=8F=B7=20=E3=80=90=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E3=80=91=E4=BF=AE=E5=A4=8D=E6=96=B0=E6=97=A7let?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E4=B8=8D=E7=BB=9F=E4=B8=80=E7=9A=84=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/cert/apply/account.go | 27 +++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/backend/internal/cert/apply/account.go b/backend/internal/cert/apply/account.go index 18bcd95..34e924d 100644 --- a/backend/internal/cert/apply/account.go +++ b/backend/internal/cert/apply/account.go @@ -50,12 +50,18 @@ func SaveUserToDB(db *public.Sqlite, user *MyUser, Type string) error { Bytes: keyBytes, }) now := time.Now().Format("2006-01-02 15:04:05") - data, err := db.Where(`email=? and type=?`, []interface{}{user.Email, Type}).Select() + var data []map[string]interface{} + if Type == "letsencrypt" || Type == "Let's Encrypt" { + data, err = db.Where(`email=? and type in ('letsencrypt','Let''s Encrypt')`, []interface{}{user.Email}).Select() + } else { + data, err = db.Where(`email=? and type=?`, []interface{}{user.Email, Type}).Select() + } + if err != nil { return err } if len(data) > 0 { - _, err = db.Update(map[string]interface{}{ + _, err = db.Where(`id = ?`, []interface{}{data[0]["id"]}).Update(map[string]interface{}{ "private_key": string(pemBytes), "reg": regBytes, "update_time": now, @@ -112,7 +118,13 @@ func GetAcmeUser(email string, logger *public.Logger, accData map[string]any) (u } func GetAccount(db *public.Sqlite, email, ca string) (map[string]interface{}, error) { - data, err := db.Where(`email=? and type=?`, []interface{}{email, ca}).Select() + var data []map[string]interface{} + var err error + if ca == "letsencrypt" || ca == "Let's Encrypt" { + data, err = db.Where(`email=? and type in ('letsencrypt','Let''s Encrypt')`, []interface{}{email}).Select() + } else { + data, err = db.Where(`email=? and type=?`, []interface{}{email, ca}).Select() + } if err != nil { return nil, err } @@ -204,11 +216,12 @@ func GetAccountList(search, ca string, p, limit int64) ([]map[string]interface{} if ca == "custom" { whereSql += `and type not in ('Let's Encrypt','buypass', 'google', 'sslcom', 'zerossl')` } else { - if ca == "letsencrypt" { - ca = "Let's Encrypt" + if ca == "letsencrypt" || ca == "Let's Encrypt" { + whereSql += " and type in ('Let''s Encrypt', 'letsencrypt')" + } else { + whereSql += " and type=?" + whereArgs = append(whereArgs, ca) } - whereSql += " and type=?" - whereArgs = append(whereArgs, ca) } } count, err := db.Where(whereSql, whereArgs).Count()