Added configurable HTTP Basic Auth.

This commit is contained in:
Patrick Fairbank
2015-08-22 23:33:38 -07:00
parent bd098de716
commit 5e49142ef0
23 changed files with 305 additions and 4 deletions

View File

@@ -21,6 +21,10 @@ var cachedTeamFirstMatches map[int]string
// Shows the schedule editing page.
func ScheduleGetHandler(w http.ResponseWriter, r *http.Request) {
if !UserIsAdmin(w, r) {
return
}
if len(cachedScheduleBlocks) == 0 {
tomorrow := time.Now().AddDate(0, 0, 1)
location, _ := time.LoadLocation("Local")
@@ -33,6 +37,10 @@ func ScheduleGetHandler(w http.ResponseWriter, r *http.Request) {
// Generates the schedule and presents it for review without saving it to the database.
func ScheduleGeneratePostHandler(w http.ResponseWriter, r *http.Request) {
if !UserIsAdmin(w, r) {
return
}
r.ParseForm()
cachedMatchType = r.PostFormValue("matchType")
scheduleBlocks, err := getScheduleBlocks(r)
@@ -88,6 +96,10 @@ func ScheduleGeneratePostHandler(w http.ResponseWriter, r *http.Request) {
// Saves the generated schedule to the database.
func ScheduleSavePostHandler(w http.ResponseWriter, r *http.Request) {
if !UserIsAdmin(w, r) {
return
}
existingMatches, err := db.GetMatchesByType(cachedMatchType)
if err != nil {
handleWebErr(w, err)