Use initial name instead of ID
This commit is contained in:
parent
467641f4f2
commit
61f96a643c
@ -22,7 +22,7 @@ func nginxGenTeam() (string, error) {
|
|||||||
} else {
|
} else {
|
||||||
ret := ""
|
ret := ""
|
||||||
for _, team := range teams {
|
for _, team := range teams {
|
||||||
ret += fmt.Sprintf(" if ($ssl_client_s_dn ~ \"/C=FR/ST=France/O=Epita/OU=SRS/CN=%s\") { set $team %d; }\n", team.InitialName, team.Id)
|
ret += fmt.Sprintf(" if ($ssl_client_s_dn ~ \"/C=FR/ST=France/O=Epita/OU=SRS/CN=%s\") { set $team \"%s\"; }\n", team.InitialName, team.InitialName)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret, nil
|
return ret, nil
|
||||||
|
@ -44,13 +44,15 @@ func (s SubmissionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse arguments
|
// Parse arguments
|
||||||
if team, err := strconv.Atoi(sURL[1]); err != nil {
|
if _, err := os.Stat(path.Join(TeamsDir, sURL[1])); os.IsNotExist(err) || len(sURL[1]) < 1 || sURL[1][0] == '_' {
|
||||||
http.Error(w, "{\"errmsg\":\"Requête invalide.\"}", http.StatusBadRequest)
|
http.Error(w, "{\"errmsg\":\"Requête invalide.\"}", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
} else if pex, err := strconv.Atoi(sURL[2]); (s.DenyChName || sURL[2] != "name") && err != nil {
|
} else if pex, err := strconv.Atoi(sURL[2]); (s.DenyChName || sURL[2] != "name") && err != nil {
|
||||||
http.Error(w, "{\"errmsg\":\"Requête invalide.\"}", http.StatusBadRequest)
|
http.Error(w, "{\"errmsg\":\"Requête invalide.\"}", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
team := sURL[1]
|
||||||
|
|
||||||
var exercice string
|
var exercice string
|
||||||
if sURL[2] == "name" {
|
if sURL[2] == "name" {
|
||||||
exercice = sURL[2]
|
exercice = sURL[2]
|
||||||
@ -64,9 +66,9 @@ func (s SubmissionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(path.Join(SubmissionDir, fmt.Sprintf("%d", team))); os.IsNotExist(err) {
|
if _, err := os.Stat(path.Join(SubmissionDir, team)); os.IsNotExist(err) {
|
||||||
log.Println("Creating submission directory for", team)
|
log.Println("Creating submission directory for", team)
|
||||||
if err := os.MkdirAll(path.Join(SubmissionDir, fmt.Sprintf("%d", team)), 0777); err != nil {
|
if err := os.MkdirAll(path.Join(SubmissionDir, team), 0777); err != nil {
|
||||||
log.Println("Unable to create submission directory: ", err)
|
log.Println("Unable to create submission directory: ", err)
|
||||||
http.Error(w, "{\"errmsg\":\"Internal server error. Please retry in few seconds.\"}", http.StatusInternalServerError)
|
http.Error(w, "{\"errmsg\":\"Internal server error. Please retry in few seconds.\"}", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@ -74,7 +76,7 @@ func (s SubmissionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Previous submission not treated
|
// Previous submission not treated
|
||||||
if _, err := os.Stat(path.Join(SubmissionDir, fmt.Sprintf("%d", team), exercice)); !os.IsNotExist(err) {
|
if _, err := os.Stat(path.Join(SubmissionDir, team, exercice)); !os.IsNotExist(err) {
|
||||||
http.Error(w, "{\"errmsg\":\"Du calme ! une requête est déjà en cours de traitement.\"}", http.StatusPaymentRequired)
|
http.Error(w, "{\"errmsg\":\"Du calme ! une requête est déjà en cours de traitement.\"}", http.StatusPaymentRequired)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -95,7 +97,7 @@ func (s SubmissionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store content in file
|
// Store content in file
|
||||||
if file, err := os.Create(path.Join(SubmissionDir, fmt.Sprintf("%d", team), exercice)); err != nil {
|
if file, err := os.Create(path.Join(SubmissionDir, team, exercice)); err != nil {
|
||||||
log.Println("Unable to open exercice file:", err)
|
log.Println("Unable to open exercice file:", err)
|
||||||
http.Error(w, "{\"errmsg\":\"Internal server error. Please retry in few seconds.\"}", http.StatusInternalServerError)
|
http.Error(w, "{\"errmsg\":\"Internal server error. Please retry in few seconds.\"}", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user