remove build artifacts that should not be checked in
This commit is contained in:
parent
f4be03ceba
commit
3cb21bf5cf
102 changed files with 461 additions and 424 deletions
|
|
@ -32,7 +32,7 @@ func (h *StatsHandler) Get(w http.ResponseWriter, r *http.Request) {
|
|||
domains = []db.DomainStats{}
|
||||
}
|
||||
|
||||
users, err := h.db.GetAllUsers()
|
||||
users, err := h.db.GetAllMailUsers()
|
||||
if err != nil {
|
||||
users = []db.User{}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ func (h *UserHandler) ListAll(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
users, err := h.db.GetAllUsers()
|
||||
users, err := h.db.GetAllMailUsers()
|
||||
if err != nil {
|
||||
Error(w, http.StatusInternalServerError, "database error")
|
||||
return
|
||||
|
|
@ -301,51 +301,4 @@ func extractDomainNameFromPath(path string) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func requireAuth(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if GetAuthContext(r) == nil {
|
||||
http.Error(w, `{"error":"authentication required"}`, http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
func requireAdmin(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
authCtx := GetAuthContext(r)
|
||||
if authCtx == nil || !authCtx.IsAdmin() {
|
||||
http.Error(w, `{"error":"admin access required"}`, http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
func checkDomainAccess(database *db.DB) func(http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
authCtx := GetAuthContext(r)
|
||||
if authCtx == nil {
|
||||
http.Error(w, `{"error":"authentication required"}`, http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
domainName := extractDomainNameFromPath(r.URL.Path)
|
||||
if domainName == "" {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
canAccess, _ := database.CanAccessDomain(authCtx.UserID, domainName, authCtx.IsAdmin())
|
||||
if !canAccess {
|
||||
http.Error(w, `{"error":"access denied"}`, http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var _ = auth.RoleAdmin
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue