mirror of https://github.com/allinssl/allinssl
parent
6d0732fc31
commit
e53a88e4dd
|
@ -50,12 +50,18 @@ func SaveUserToDB(db *public.Sqlite, user *MyUser, Type string) error {
|
||||||
Bytes: keyBytes,
|
Bytes: keyBytes,
|
||||||
})
|
})
|
||||||
now := time.Now().Format("2006-01-02 15:04:05")
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(data) > 0 {
|
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),
|
"private_key": string(pemBytes),
|
||||||
"reg": regBytes,
|
"reg": regBytes,
|
||||||
"update_time": now,
|
"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) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -204,13 +216,14 @@ func GetAccountList(search, ca string, p, limit int64) ([]map[string]interface{}
|
||||||
if ca == "custom" {
|
if ca == "custom" {
|
||||||
whereSql += `and type not in ('Let's Encrypt','buypass', 'google', 'sslcom', 'zerossl')`
|
whereSql += `and type not in ('Let's Encrypt','buypass', 'google', 'sslcom', 'zerossl')`
|
||||||
} else {
|
} else {
|
||||||
if ca == "letsencrypt" {
|
if ca == "letsencrypt" || ca == "Let's Encrypt" {
|
||||||
ca = "Let's Encrypt"
|
whereSql += " and type in ('Let''s Encrypt', 'letsencrypt')"
|
||||||
}
|
} else {
|
||||||
whereSql += " and type=?"
|
whereSql += " and type=?"
|
||||||
whereArgs = append(whereArgs, ca)
|
whereArgs = append(whereArgs, ca)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
count, err := db.Where(whereSql, whereArgs).Count()
|
count, err := db.Where(whereSql, whereArgs).Count()
|
||||||
data, err := db.Where(whereSql, whereArgs).Limit(limits).Select()
|
data, err := db.Where(whereSql, whereArgs).Limit(limits).Select()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue