Skip to content

Commit 42a28b4

Browse files
committed
Enforce non-whitespace group name
1 parent 373e034 commit 42a28b4

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎src/Ctf4e.Server/Controllers/AuthenticationController.GroupSelection.cs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,16 @@ public async Task<IActionResult> HandleGroupSelectionAsync(GroupSelection groupS
7676
return await ShowGroupFormAsync(groupSelection);
7777
}
7878

79+
// Enforce group name
80+
string groupName = groupSelection.DisplayName?.Trim();
81+
if(string.IsNullOrWhiteSpace(groupName))
82+
groupName = $"group{Random.Shared.Next(10000, 100000)}";
83+
7984
// Create group
8085
// The service method will do further error checking (i.e., validity of codes, whether users are already in a group, ...)
8186
var group = new Group
8287
{
83-
DisplayName = groupSelection.DisplayName ?? $"group{Random.Shared.Next(10000, 100000)}",
88+
DisplayName = groupName,
8489
SlotId = groupSelection.SlotId,
8590
ShowInScoreboard = groupSelection.ShowInScoreboard
8691
};

0 commit comments

Comments
 (0)