New option to allow teams to self reset their progression
This commit is contained in:
parent
a0c34018cf
commit
d6ff46ca7f
9 changed files with 173 additions and 3 deletions
26
receiver/reset.go
Normal file
26
receiver/reset.go
Normal 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)
|
||||
}
|
||||
}
|
Reference in a new issue