host fix ID
This commit is contained in:
parent
6a350ac9fb
commit
23df4767da
|
@ -22,11 +22,12 @@ func getDatabase(ctx context.Context, w http.ResponseWriter) (database Database,
|
|||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
database = Database{ID: id}
|
||||
|
||||
if login.Superadmin {
|
||||
dbconnection.Where("id = ?", id).Find(&database)
|
||||
dbconnection.Find(&database)
|
||||
} else {
|
||||
dbconnection.Where(map[string]int64{"id": id, "profil": profil.ID}).Find(&database)
|
||||
dbconnection.Where(map[string]int64{"profil": profil.ID}).Find(&database)
|
||||
}
|
||||
|
||||
if database.ID <= 0 {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package host
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -36,9 +35,6 @@ func getDomain(ctx context.Context, w http.ResponseWriter) (domain Domain, retur
|
|||
returnerr = &libapi.ErrorResult{Fields: []string{"domain"}, Message: "not found"}
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
}
|
||||
if id != domain.ID {
|
||||
fmt.Printf("want %d, get %d", id, domain.ID)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -23,10 +23,12 @@ func getMail(ctx context.Context, w http.ResponseWriter) (mail Mail, returnerr *
|
|||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
mail = Mail{ID: id}
|
||||
|
||||
if login.Superadmin {
|
||||
dbconnection.Where(map[string]int64{"ID": id}).Preload("Forwards").Find(&mail)
|
||||
dbconnection.Preload("Forwards").Find(&mail)
|
||||
} else {
|
||||
dbconnection.Where(map[string]int64{"ID": id, "domain.profil": profil.ID}).Preload("Forwards").Find(&mail)
|
||||
dbconnection.Where(map[string]int64{"domain.profil": profil.ID}).Preload("Forwards").Find(&mail)
|
||||
}
|
||||
if mail.ID <= 0 {
|
||||
returnerr = &libapi.ErrorResult{Fields: []string{"mail"}, Message: "not found"}
|
||||
|
|
|
@ -36,10 +36,11 @@ func getWeb(ctx context.Context, w http.ResponseWriter) (web Web, returnerr *lib
|
|||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
web = Web{ID: id}
|
||||
if login.Superadmin {
|
||||
dbconnection.Where(map[string]int64{"ID": id}).Preload("HTTPAccess.Login").Preload("FTPAccess.Login").Find(&web)
|
||||
dbconnection.Preload("HTTPAccess.Login").Preload("FTPAccess.Login").Find(&web)
|
||||
} else {
|
||||
dbconnection.Where(map[string]int64{"ID": id, "domain.profil": profil.ID}).Preload("HTTPAccess.Login").Preload("FTPAccess.Login").Find(&web)
|
||||
dbconnection.Where(map[string]int64{"domain.profil": profil.ID}).Preload("HTTPAccess.Login").Preload("FTPAccess.Login").Find(&web)
|
||||
}
|
||||
if web.ID <= 0 {
|
||||
returnerr = &libapi.ErrorResult{Fields: []string{"web"}, Message: "not found"}
|
||||
|
|
Reference in New Issue