diff options
Diffstat (limited to 'Jellyfin.Api/Controllers/StartupController.cs')
| -rw-r--r-- | Jellyfin.Api/Controllers/StartupController.cs | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs index 57a02e62a..d96b0f993 100644 --- a/Jellyfin.Api/Controllers/StartupController.cs +++ b/Jellyfin.Api/Controllers/StartupController.cs @@ -33,16 +33,16 @@ namespace Jellyfin.Api.Controllers /// <summary> /// Completes the startup wizard. /// </summary> - /// <response code="200">Startup wizard completed.</response> - /// <returns>An <see cref="OkResult"/> indicating success.</returns> + /// <response code="204">Startup wizard completed.</response> + /// <returns>A <see cref="NoContentResult"/> indicating success.</returns> [HttpPost("Complete")] - [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult CompleteWizard() { _config.Configuration.IsStartupWizardCompleted = true; _config.SetOptimalValues(); _config.SaveConfiguration(); - return Ok(); + return NoContent(); } /// <summary> @@ -70,10 +70,10 @@ namespace Jellyfin.Api.Controllers /// <param name="uiCulture">The UI language culture.</param> /// <param name="metadataCountryCode">The metadata country code.</param> /// <param name="preferredMetadataLanguage">The preferred language for metadata.</param> - /// <response code="200">Configuration saved.</response> - /// <returns>An <see cref="OkResult"/> indicating success.</returns> + /// <response code="204">Configuration saved.</response> + /// <returns>A <see cref="NoContentResult"/> indicating success.</returns> [HttpPost("Configuration")] - [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult UpdateInitialConfiguration( [FromForm] string uiCulture, [FromForm] string metadataCountryCode, @@ -83,7 +83,7 @@ namespace Jellyfin.Api.Controllers _config.Configuration.MetadataCountryCode = metadataCountryCode; _config.Configuration.PreferredMetadataLanguage = preferredMetadataLanguage; _config.SaveConfiguration(); - return Ok(); + return NoContent(); } /// <summary> @@ -91,16 +91,16 @@ namespace Jellyfin.Api.Controllers /// </summary> /// <param name="enableRemoteAccess">Enable remote access.</param> /// <param name="enableAutomaticPortMapping">Enable UPnP.</param> - /// <response code="200">Configuration saved.</response> - /// <returns>An <see cref="OkResult"/> indicating success.</returns> + /// <response code="204">Configuration saved.</response> + /// <returns>A <see cref="NoContentResult"/> indicating success.</returns> [HttpPost("RemoteAccess")] - [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SetRemoteAccess([FromForm] bool enableRemoteAccess, [FromForm] bool enableAutomaticPortMapping) { _config.Configuration.EnableRemoteAccess = enableRemoteAccess; _config.Configuration.EnableUPnP = enableAutomaticPortMapping; _config.SaveConfiguration(); - return Ok(); + return NoContent(); } /// <summary> @@ -113,35 +113,41 @@ namespace Jellyfin.Api.Controllers [ProducesResponseType(StatusCodes.Status200OK)] public ActionResult<StartupUserDto> GetFirstUser() { + // TODO: Remove this method when startup wizard no longer requires an existing user. + _userManager.Initialize(); var user = _userManager.Users.First(); - return new StartupUserDto { Name = user.Name, Password = user.Password }; + return new StartupUserDto + { + Name = user.Username, + Password = user.Password + }; } /// <summary> /// Sets the user name and password. /// </summary> /// <param name="startupUserDto">The DTO containing username and password.</param> - /// <response code="200">Updated user name and password.</response> + /// <response code="204">Updated user name and password.</response> /// <returns> /// A <see cref="Task" /> that represents the asynchronous update operation. - /// The task result contains an <see cref="OkResult"/> indicating success. + /// The task result contains a <see cref="NoContentResult"/> indicating success. /// </returns> [HttpPost("User")] - [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status204NoContent)] public async Task<ActionResult> UpdateUser([FromForm] StartupUserDto startupUserDto) { var user = _userManager.Users.First(); - user.Name = startupUserDto.Name; + user.Username = startupUserDto.Name; - _userManager.UpdateUser(user); + await _userManager.UpdateUserAsync(user).ConfigureAwait(false); if (!string.IsNullOrEmpty(startupUserDto.Password)) { await _userManager.ChangePassword(user, startupUserDto.Password).ConfigureAwait(false); } - return Ok(); + return NoContent(); } } } |
