small fixes
This commit is contained in:
@@ -251,7 +251,7 @@ func (s *ClientService) UpdateClientsOnInboundDelete(tx *gorm.DB, id uint, tag s
|
|||||||
func (s *ClientService) UpdateLinksByInboundChange(tx *gorm.DB, inbounIds []uint, hostname string) error {
|
func (s *ClientService) UpdateLinksByInboundChange(tx *gorm.DB, inbounIds []uint, hostname string) error {
|
||||||
var inbounds []model.Inbound
|
var inbounds []model.Inbound
|
||||||
err := tx.Model(model.Inbound{}).Preload("Tls").Where("id in ? and type in ?", inbounIds, util.InboundTypeWithLink).Find(&inbounds).Error
|
err := tx.Model(model.Inbound{}).Preload("Tls").Where("id in ? and type in ?", inbounIds, util.InboundTypeWithLink).Find(&inbounds).Error
|
||||||
if err != nil && err != gorm.ErrRecordNotFound {
|
if err != nil && database.IsNotFound(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, inbound := range inbounds {
|
for _, inbound := range inbounds {
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func (s *InboundService) FromIds(ids []uint) ([]*model.Inbound, error) {
|
|||||||
return inbounds, nil
|
return inbounds, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *InboundService) Save(tx *gorm.DB, act string, data json.RawMessage, initUsers string, hostname string) (uint, error) {
|
func (s *InboundService) Save(tx *gorm.DB, act string, data json.RawMessage, initUserIds string, hostname string) (uint, error) {
|
||||||
var err error
|
var err error
|
||||||
var id uint
|
var id uint
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ func (s *InboundService) Save(tx *gorm.DB, act string, data json.RawMessage, ini
|
|||||||
if act == "edit" {
|
if act == "edit" {
|
||||||
inboundConfig, err = s.addUsers(tx, inboundConfig, inbound.Id, inbound.Type)
|
inboundConfig, err = s.addUsers(tx, inboundConfig, inbound.Id, inbound.Type)
|
||||||
} else {
|
} else {
|
||||||
inboundConfig, err = s.initUsers(tx, inboundConfig, initUsers, inbound.Id, inbound.Type)
|
inboundConfig, err = s.initUsers(tx, inboundConfig, initUserIds, inbound.Type)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@@ -270,7 +270,7 @@ func (s *InboundService) addUsers(db *gorm.DB, inboundJson []byte, inboundId uin
|
|||||||
return json.Marshal(inbound)
|
return json.Marshal(inbound)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *InboundService) initUsers(db *gorm.DB, inboundJson []byte, clientIds string, inboundId uint, inboundType string) ([]byte, error) {
|
func (s *InboundService) initUsers(db *gorm.DB, inboundJson []byte, clientIds string, inboundType string) ([]byte, error) {
|
||||||
ClientIds := strings.Split(clientIds, ",")
|
ClientIds := strings.Split(clientIds, ",")
|
||||||
if len(ClientIds) == 0 {
|
if len(ClientIds) == 0 {
|
||||||
return inboundJson, nil
|
return inboundJson, nil
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import (
|
|||||||
"s-ui/logger"
|
"s-ui/logger"
|
||||||
"s-ui/util/common"
|
"s-ui/util/common"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserService struct {
|
type UserService struct {
|
||||||
@@ -63,7 +61,7 @@ func (s *UserService) CheckUser(username string, password string, remoteIP strin
|
|||||||
Where("username = ? and password = ?", username, password).
|
Where("username = ? and password = ?", username, password).
|
||||||
First(user).
|
First(user).
|
||||||
Error
|
Error
|
||||||
if err == gorm.ErrRecordNotFound {
|
if database.IsNotFound(err) {
|
||||||
return nil
|
return nil
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
logger.Warning("check user err:", err, " IP: ", remoteIP)
|
logger.Warning("check user err:", err, " IP: ", remoteIP)
|
||||||
|
|||||||
Reference in New Issue
Block a user