sum7/warehost
sum7
/
warehost
Archived
1
0
Fork 0

host fix ID

This commit is contained in:
Martin Geno 2016-12-13 12:49:17 +01:00
parent 6a350ac9fb
commit 23df4767da
4 changed files with 10 additions and 10 deletions

View File

@ -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 {

View File

@ -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
}

View File

@ -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"}

View File

@ -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"}