Merge pull request #2953 from crobibero/api-startup
Convert StartupController to ActionResult
This commit is contained in:
commit
5c95037234
|
@ -5,6 +5,7 @@ using Jellyfin.Api.Models.StartupDtos;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace Jellyfin.Api.Controllers
|
namespace Jellyfin.Api.Controllers
|
||||||
|
@ -30,22 +31,28 @@ namespace Jellyfin.Api.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Api endpoint for completing the startup wizard.
|
/// Completes the startup wizard.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <response code="200">Startup wizard completed.</response>
|
||||||
|
/// <returns>An <see cref="OkResult"/> indicating success.</returns>
|
||||||
[HttpPost("Complete")]
|
[HttpPost("Complete")]
|
||||||
public void CompleteWizard()
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
public ActionResult CompleteWizard()
|
||||||
{
|
{
|
||||||
_config.Configuration.IsStartupWizardCompleted = true;
|
_config.Configuration.IsStartupWizardCompleted = true;
|
||||||
_config.SetOptimalValues();
|
_config.SetOptimalValues();
|
||||||
_config.SaveConfiguration();
|
_config.SaveConfiguration();
|
||||||
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Endpoint for getting the initial startup wizard configuration.
|
/// Gets the initial startup wizard configuration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The initial startup wizard configuration.</returns>
|
/// <response code="200">Initial startup wizard configuration retrieved.</response>
|
||||||
|
/// <returns>An <see cref="OkResult"/> containing the initial startup wizard configuration.</returns>
|
||||||
[HttpGet("Configuration")]
|
[HttpGet("Configuration")]
|
||||||
public StartupConfigurationDto GetStartupConfiguration()
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
public ActionResult<StartupConfigurationDto> GetStartupConfiguration()
|
||||||
{
|
{
|
||||||
var result = new StartupConfigurationDto
|
var result = new StartupConfigurationDto
|
||||||
{
|
{
|
||||||
|
@ -58,13 +65,16 @@ namespace Jellyfin.Api.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Endpoint for updating the initial startup wizard configuration.
|
/// Sets the initial startup wizard configuration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uiCulture">The UI language culture.</param>
|
/// <param name="uiCulture">The UI language culture.</param>
|
||||||
/// <param name="metadataCountryCode">The metadata country code.</param>
|
/// <param name="metadataCountryCode">The metadata country code.</param>
|
||||||
/// <param name="preferredMetadataLanguage">The preferred language for metadata.</param>
|
/// <param name="preferredMetadataLanguage">The preferred language for metadata.</param>
|
||||||
|
/// <response code="200">Configuration saved.</response>
|
||||||
|
/// <returns>An <see cref="OkResult"/> indicating success.</returns>
|
||||||
[HttpPost("Configuration")]
|
[HttpPost("Configuration")]
|
||||||
public void UpdateInitialConfiguration(
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
public ActionResult UpdateInitialConfiguration(
|
||||||
[FromForm] string uiCulture,
|
[FromForm] string uiCulture,
|
||||||
[FromForm] string metadataCountryCode,
|
[FromForm] string metadataCountryCode,
|
||||||
[FromForm] string preferredMetadataLanguage)
|
[FromForm] string preferredMetadataLanguage)
|
||||||
|
@ -73,43 +83,51 @@ namespace Jellyfin.Api.Controllers
|
||||||
_config.Configuration.MetadataCountryCode = metadataCountryCode;
|
_config.Configuration.MetadataCountryCode = metadataCountryCode;
|
||||||
_config.Configuration.PreferredMetadataLanguage = preferredMetadataLanguage;
|
_config.Configuration.PreferredMetadataLanguage = preferredMetadataLanguage;
|
||||||
_config.SaveConfiguration();
|
_config.SaveConfiguration();
|
||||||
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Endpoint for (dis)allowing remote access and UPnP.
|
/// Sets remote access and UPnP.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="enableRemoteAccess">Enable remote access.</param>
|
/// <param name="enableRemoteAccess">Enable remote access.</param>
|
||||||
/// <param name="enableAutomaticPortMapping">Enable UPnP.</param>
|
/// <param name="enableAutomaticPortMapping">Enable UPnP.</param>
|
||||||
|
/// <response code="200">Configuration saved.</response>
|
||||||
|
/// <returns>An <see cref="OkResult"/> indicating success.</returns>
|
||||||
[HttpPost("RemoteAccess")]
|
[HttpPost("RemoteAccess")]
|
||||||
public void SetRemoteAccess([FromForm] bool enableRemoteAccess, [FromForm] bool enableAutomaticPortMapping)
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
public ActionResult SetRemoteAccess([FromForm] bool enableRemoteAccess, [FromForm] bool enableAutomaticPortMapping)
|
||||||
{
|
{
|
||||||
_config.Configuration.EnableRemoteAccess = enableRemoteAccess;
|
_config.Configuration.EnableRemoteAccess = enableRemoteAccess;
|
||||||
_config.Configuration.EnableUPnP = enableAutomaticPortMapping;
|
_config.Configuration.EnableUPnP = enableAutomaticPortMapping;
|
||||||
_config.SaveConfiguration();
|
_config.SaveConfiguration();
|
||||||
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Endpoint for returning the first user.
|
/// Gets the first user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <response code="200">Initial user retrieved.</response>
|
||||||
/// <returns>The first user.</returns>
|
/// <returns>The first user.</returns>
|
||||||
[HttpGet("User")]
|
[HttpGet("User")]
|
||||||
public StartupUserDto GetFirstUser()
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
public ActionResult<StartupUserDto> GetFirstUser()
|
||||||
{
|
{
|
||||||
var user = _userManager.Users.First();
|
var user = _userManager.Users.First();
|
||||||
return new StartupUserDto
|
return new StartupUserDto { Name = user.Name, Password = user.Password };
|
||||||
{
|
|
||||||
Name = user.Name,
|
|
||||||
Password = user.Password
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Endpoint for updating the user name and password.
|
/// Sets the user name and password.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="startupUserDto">The DTO containing username and password.</param>
|
/// <param name="startupUserDto">The DTO containing username and password.</param>
|
||||||
/// <returns>The async task.</returns>
|
/// <response code="200">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.
|
||||||
|
/// </returns>
|
||||||
[HttpPost("User")]
|
[HttpPost("User")]
|
||||||
public async Task UpdateUser([FromForm] StartupUserDto startupUserDto)
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
public async Task<ActionResult> UpdateUser([FromForm] StartupUserDto startupUserDto)
|
||||||
{
|
{
|
||||||
var user = _userManager.Users.First();
|
var user = _userManager.Users.First();
|
||||||
|
|
||||||
|
@ -121,6 +139,8 @@ namespace Jellyfin.Api.Controllers
|
||||||
{
|
{
|
||||||
await _userManager.ChangePassword(user, startupUserDto.Password).ConfigureAwait(false);
|
await _userManager.ChangePassword(user, startupUserDto.Password).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user