diff options
| author | Joshua M. Boniface <joshua@boniface.me> | 2025-08-03 17:27:50 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-03 17:27:50 -0400 |
| commit | ce78af2ed4f203690a0f9ef87b08b27a6bd43f63 (patch) | |
| tree | 15f986ee62327cceb8f5c8f009bcf08d10cfaa66 /Jellyfin.Api/Controllers/StartupController.cs | |
| parent | db7465e83d9cc07134a0bffad7ed17b1c7b873da (diff) | |
| parent | 4b6fb6c4bb2478badad068ce18aabe0c2955db48 (diff) | |
Merge pull request #13604 from Jxiced/master
Prevent whitespaces in username during wizard setup
Diffstat (limited to 'Jellyfin.Api/Controllers/StartupController.cs')
| -rw-r--r-- | Jellyfin.Api/Controllers/StartupController.cs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs index 09f20558f..3bb68553d 100644 --- a/Jellyfin.Api/Controllers/StartupController.cs +++ b/Jellyfin.Api/Controllers/StartupController.cs @@ -1,3 +1,4 @@ +using System; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; @@ -131,16 +132,16 @@ public class StartupController : BaseJellyfinApiController [ProducesResponseType(StatusCodes.Status204NoContent)] public async Task<ActionResult> UpdateStartupUser([FromBody] StartupUserDto startupUserDto) { + ArgumentNullException.ThrowIfNull(startupUserDto.Name); + _userManager.ThrowIfInvalidUsername(startupUserDto.Name); + var user = _userManager.Users.First(); if (string.IsNullOrWhiteSpace(startupUserDto.Password)) { return BadRequest("Password must not be empty"); } - if (startupUserDto.Name is not null) - { - user.Username = startupUserDto.Name; - } + user.Username = startupUserDto.Name; await _userManager.UpdateUserAsync(user).ConfigureAwait(false); |
