quick patch that lets someone with write access restart a build

This commit is contained in:
Brad Rydzewski 2015-02-23 23:43:17 -08:00
parent a1e44f4e1b
commit 293d503cad

View file

@ -2,6 +2,7 @@ package middleware
import (
"net/http"
"regexp"
"github.com/drone/drone/server/datastore"
"github.com/goji/context"
@ -89,6 +90,13 @@ func RequireRepoAdmin(c *web.C, h http.Handler) http.Handler {
case user != nil && role.Read == false && role.Admin == false:
w.WriteHeader(http.StatusNotFound)
return
case user != nil && role.Write == true && role.Admin == false:
if IsRebuild(r.URL.Path) {
h.ServeHTTP(w, r)
return
}
w.WriteHeader(http.StatusForbidden)
return
case user != nil && role.Read == true && role.Admin == false:
w.WriteHeader(http.StatusForbidden)
return
@ -100,3 +108,9 @@ func RequireRepoAdmin(c *web.C, h http.Handler) http.Handler {
}
return http.HandlerFunc(fn)
}
func IsRebuild(path string) bool {
const pattern = `\/(.*)\/(.*)\/(.*)\/branches\/(.*)\/commits\/(.*)`
ok, _ := regexp.MatchString(pattern, path)
return ok
}