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

@ -178,6 +178,7 @@ func main() {
WChoiceCurCoefficient: 1, WChoiceCurCoefficient: 1,
AllowRegistration: false, AllowRegistration: false,
CanJoinTeam: false, CanJoinTeam: false,
DenyTeamCreation: false,
DenyNameChange: false, DenyNameChange: false,
AcceptNewIssue: true, AcceptNewIssue: true,
EnableResolutionRoute: false, EnableResolutionRoute: false,

View file

@ -129,6 +129,13 @@
</label> </label>
</div> </div>
<div class="form-check">
<label class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" ng-model="config.denyTeamCreation" ng-disabled="!config.allowRegistration && !config.canJoinTeam">
<span class="custom-control-label">Interdire la création de nouvelles équipes</span>
</label>
</div>
<div class="form-check"> <div class="form-check">
<label class="custom-control custom-checkbox"> <label class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" ng-model="config.denyNameChange"> <input class="custom-control-input" type="checkbox" ng-model="config.denyNameChange">

View file

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

View file

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

View file

@ -9,9 +9,9 @@
</div> </div>
</div> </div>
<div class="jumbotron niceborder" style="text-indent: 1em" ng-if="settings.allowRegistration"> <div class="jumbotron niceborder" style="text-indent: 1em" ng-if="settings.allowRegistration && !settings.denyTeamCreation">
<p> <p>
<strong>Félicitations&nbsp;! vous êtes maintenant authentifié auprès de <strong>Félicitations&nbsp;! vous êtes maintenant authentifié&middot;e auprès de
notre serveur&nbsp;!</strong> notre serveur&nbsp;!</strong>
</p> </p>
<p> <p>
@ -76,9 +76,18 @@
</div> </div>
<div class="jumbotron niceborder" style="text-indent: 1em" ng-if="settings.canJoinTeam"> <div class="jumbotron niceborder" style="text-indent: 1em" ng-if="settings.canJoinTeam">
<p> <p ng-if="settings.denyTeamCreation">
<strong>Félicitations&nbsp;! vous êtes maintenant authentifié&middot;e auprès de
notre serveur&nbsp;!</strong>
</p>
<p ng-if="!settings.denyTeamCreation">
Si votre équipe est déjà créée, rejoignez-là&nbsp;! Si votre équipe est déjà créée, rejoignez-là&nbsp;!
</p> </p>
<p ng-if="settings.denyTeamCreation">
Vous n'êtes pas encore enregistré&middot;e sur notre serveur. Afin de
pouvoir participer au challenge, nous vous remercions de bien vouloir
rejoindre votre équipe&nbsp;:
</p>
<form ng-submit="jsubmit()"> <form ng-submit="jsubmit()">
<div class="row"> <div class="row">

View file

@ -8,8 +8,8 @@ import (
"os" "os"
"os/signal" "os/signal"
"path" "path"
"time"
"syscall" "syscall"
"time"
"gopkg.in/fsnotify.v1" "gopkg.in/fsnotify.v1"
) )
@ -53,6 +53,8 @@ type FICSettings struct {
AllowRegistration bool `json:"allowRegistration"` AllowRegistration bool `json:"allowRegistration"`
// CanJoinTeam permits unregistered account to join an already existing team. // CanJoinTeam permits unregistered account to join an already existing team.
CanJoinTeam bool `json:"canJoinTeam"` CanJoinTeam bool `json:"canJoinTeam"`
// DenyTeamCreation forces unregistered account to join a team, it's not possible to create a new team.
DenyTeamCreation bool `json:"denyTeamCreation"`
// DenyNameChange disallow Team to change their name. // DenyNameChange disallow Team to change their name.
DenyNameChange bool `json:"denyNameChange"` DenyNameChange bool `json:"denyNameChange"`
// AcceptNewIssue enables the reporting system. // AcceptNewIssue enables the reporting system.