feat(ldap): add ldap protocol support (#50)

Co-authored-by: tardc <[email protected]>
Co-authored-by: E99p1ant <[email protected]>
This commit is contained in:
Li4n0
2022-01-07 22:47:02 +08:00
committed by GitHub
co-authored by tardc E99p1ant
parent 06ae3d0555
commit fc505b0733
46 changed files with 1356 additions and 135 deletions
+3 -13
View File
@@ -96,10 +96,7 @@ func ListRules(c *gin.Context) {
}
db := database.DB.Model(&ftpRule)
if ftpRule.Name != "" {
db.Where("name = ?", ftpRule.Name)
}
db.Count(&count)
db.Where(&ftpRule).Count(&count)
page, err := strconv.Atoi(c.Query("page"))
if err != nil {
@@ -133,10 +130,7 @@ func ListRules(c *gin.Context) {
// UpsertRules creates or updates ftp rule from user submit
func UpsertRules(c *gin.Context) {
var (
ftpRule Rule
update bool
)
var ftpRule Rule
if err := c.ShouldBind(&ftpRule); err != nil {
c.JSON(400, gin.H{
@@ -147,10 +141,6 @@ func UpsertRules(c *gin.Context) {
return
}
if ftpRule.ID != 0 {
update = true
}
if err := ftpRule.CreateOrUpdate(); err != nil {
c.JSON(400, gin.H{
"status": "failed",
@@ -160,7 +150,7 @@ func UpsertRules(c *gin.Context) {
return
}
if update {
if ftpRule.ID != 0 {
log.Trace("FTP rule[id:%d] has been updated", ftpRule.ID)
} else {
log.Trace("FTP rule[id:%d] has been created", ftpRule.ID)