New option to disallow team creation: join only

This commit is contained in:
nemunaire 2020-05-16 03:51:36 +02:00
parent 5d3ef96f3f
commit 64b9e9a251
6 changed files with 53 additions and 30 deletions

View file

@ -70,6 +70,7 @@ var skipInitialGeneration = false
func reloadSettings(config settings.FICSettings) {
allowRegistration = config.AllowRegistration
canJoinTeam = config.CanJoinTeam
denyTeamCreation = config.DenyTeamCreation
fic.HintCoefficient = config.HintCurCoefficient
fic.WChoiceCoefficient = config.WChoiceCurCoefficient
fic.ExerciceCurrentCoefficient = config.ExerciceCurCoefficient

View file

@ -18,6 +18,7 @@ import (
var (
allowRegistration = false
canJoinTeam = false
denyTeamCreation = false
)
type uTeamRegistration struct {
@ -78,6 +79,8 @@ func treatRegistration(pathname string, team_id string) {
log.Printf("%s [WRN] %s\n", id, err)
}
}
} else if denyTeamCreation {
log.Printf("%s [ERR] Registration received, whereas team creation denied. Skipped.\n", id)
} else if validTeamName(nTeam.TeamName) {
if team, err := fic.CreateTeam(nTeam.TeamName, uint32(rand.Int31n(16581376))); err != nil {
log.Printf("%s [ERR] Unable to register new team %s: %s\n", id, nTeam.TeamName, err)