【修复】修复生成新的acme账号时有概率覆盖所有账号

【修复】修复新旧let账号不统一的兼容性问题
1.1.0
v-me-50 2025-08-18 15:49:26 +08:00
parent 6d0732fc31
commit e53a88e4dd
1 changed files with 20 additions and 7 deletions

View File

@ -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,13 +216,14 @@ 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)
}
}
}
count, err := db.Where(whereSql, whereArgs).Count()
data, err := db.Where(whereSql, whereArgs).Limit(limits).Select()
if err != nil {