Browse Source

minor: 重置密码,邮件发送

tuonian 3 weeks ago
parent
commit
3fc901a02c

+ 2 - 2
server/modules/ldap/organize_service.go

@@ -103,8 +103,8 @@ func (c *OrganizeService) GetDetail(id int) (*models.LdapOrganize, error) {
 func (c *OrganizeService) GetList(serverKey string) ([]models.LdapOrganize, error) {
 	o := orm.NewOrm()
 	qs := o.QueryTable(&models.LdapOrganize{})
-	qs.Filter("ServerKey", serverKey)
-	qs.OrderBy("-Id")
+	qs = qs.Filter("ServerKey", serverKey)
+	qs = qs.OrderBy("-Id")
 
 	var list []models.LdapOrganize
 	_, err := qs.All(&list)

+ 1 - 1
server/modules/ldap/server_service.go

@@ -202,7 +202,7 @@ func (c *ServerService) GetUsers(current *models.User, req *UserListReq) (*vo.Pa
 	if !current.IsAdmin() {
 		qs = qs.Filter("Uid", current.Account)
 	}
-	qs.Filter("ServerKey", req.ServerKey)
+	qs = qs.Filter("ServerKey", req.ServerKey)
 
 	total, err := qs.Count()
 	if err != nil {

+ 1 - 3
server/modules/mail/sender.go

@@ -2,10 +2,8 @@ package mail
 
 import (
 	"crypto/tls"
-	"fmt"
 	"github.com/astaxie/beego/logs"
 	"gopkg.in/gomail.v2"
-	"net/url"
 	settings2 "nginx-ui/server/modules/settings"
 	"strconv"
 	"strings"
@@ -67,7 +65,7 @@ func SendEmail(to string, subject string, body string, sender *Sender) error {
 	defer closer.Close()
 	m := gomail.NewMessage()
 
-	from := fmt.Sprintf("%s <%s>", url.QueryEscape(sender.Nickname), sender.Username)
+	from := m.FormatAddress(sender.Username, sender.Nickname)
 
 	m.SetHeader("From", from)
 	m.SetHeader("To", to)

+ 1 - 1
server/modules/settings/setting_controller.go

@@ -16,7 +16,7 @@ func (c *SettingController) List() {
 	if current == nil {
 		return
 	}
-	list, err := SettingSrv.GetList(ListVo{})
+	list, err := SettingSrv.GetList(ListVo{Enable: -1})
 	if err != nil {
 		c.ErrorJson(err)
 		return

+ 3 - 3
server/modules/settings/setting_service.go

@@ -21,12 +21,12 @@ func (c *SettingService) GetList(vo ListVo) ([]models.Setting, error) {
 	o := orm.NewOrm()
 	qs := o.QueryTable(&models.Setting{})
 	if vo.Prefix != "" {
-		qs.FilterRaw("config_key LIKE '?%'", vo.Prefix)
+		qs = qs.FilterRaw("ConfigKey", "LIKE '"+vo.Prefix+"%'")
 	}
 	if vo.Enable > -1 {
-		qs.Filter("Enable", vo.Enable)
+		qs = qs.Filter("Enable", vo.Enable)
 	}
-	qs.OrderBy("-Id")
+	qs = qs.OrderBy("-Id")
 
 	var list []models.Setting
 	_, err := qs.All(&list)