New option to allow teams to self reset their progression

This commit is contained in:
nemunaire 2023-11-04 21:14:16 +01:00
parent a0c34018cf
commit d6ff46ca7f
9 changed files with 173 additions and 3 deletions

26
receiver/reset.go Normal file
View file

@ -0,0 +1,26 @@
package main
import (
"net/http"
"path"
"time"
)
var enableResetProgression = false
func ResetProgressHandler(w http.ResponseWriter, r *http.Request, team string, sURL []string) {
if !enableResetProgression {
http.Error(w, "{\"errmsg\":\"Le challenge est terminé, trop tard !\"}", http.StatusForbidden)
return
}
if challengeEnd != nil && time.Now().After(*challengeEnd) {
http.Error(w, "{\"errmsg\":\"Le challenge est terminé, trop tard !\"}", http.StatusGone)
return
}
// Enqueue file for backend treatment
if saveTeamFile(path.Join(team, "reset_progress"), w, r) {
http.Error(w, "{\"errmsg\":\"Demande acceptée...\"}", http.StatusAccepted)
}
}