mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 19:37:55 +02:00
Convert StartupController to IActionResult
This commit is contained in:
parent
16401ec7ae
commit
b8fd9c785e
1 changed files with 23 additions and 12 deletions
|
@ -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
|
||||||
|
@ -32,12 +33,15 @@ namespace Jellyfin.Api.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Api endpoint for completing the startup wizard.
|
/// Api endpoint for completing the startup wizard.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <returns>Status.</returns>
|
||||||
[HttpPost("Complete")]
|
[HttpPost("Complete")]
|
||||||
public void CompleteWizard()
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
public IActionResult CompleteWizard()
|
||||||
{
|
{
|
||||||
_config.Configuration.IsStartupWizardCompleted = true;
|
_config.Configuration.IsStartupWizardCompleted = true;
|
||||||
_config.SetOptimalValues();
|
_config.SetOptimalValues();
|
||||||
_config.SaveConfiguration();
|
_config.SaveConfiguration();
|
||||||
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -45,7 +49,8 @@ namespace Jellyfin.Api.Controllers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The initial startup wizard configuration.</returns>
|
/// <returns>The initial startup wizard configuration.</returns>
|
||||||
[HttpGet("Configuration")]
|
[HttpGet("Configuration")]
|
||||||
public StartupConfigurationDto GetStartupConfiguration()
|
[ProducesResponseType(typeof(StartupConfigurationDto), StatusCodes.Status200OK)]
|
||||||
|
public IActionResult GetStartupConfiguration()
|
||||||
{
|
{
|
||||||
var result = new StartupConfigurationDto
|
var result = new StartupConfigurationDto
|
||||||
{
|
{
|
||||||
|
@ -54,7 +59,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
PreferredMetadataLanguage = _config.Configuration.PreferredMetadataLanguage
|
PreferredMetadataLanguage = _config.Configuration.PreferredMetadataLanguage
|
||||||
};
|
};
|
||||||
|
|
||||||
return result;
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -63,8 +68,10 @@ namespace Jellyfin.Api.Controllers
|
||||||
/// <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>
|
||||||
|
/// <returns>Status.</returns>
|
||||||
[HttpPost("Configuration")]
|
[HttpPost("Configuration")]
|
||||||
public void UpdateInitialConfiguration(
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
public IActionResult UpdateInitialConfiguration(
|
||||||
[FromForm] string uiCulture,
|
[FromForm] string uiCulture,
|
||||||
[FromForm] string metadataCountryCode,
|
[FromForm] string metadataCountryCode,
|
||||||
[FromForm] string preferredMetadataLanguage)
|
[FromForm] string preferredMetadataLanguage)
|
||||||
|
@ -73,6 +80,7 @@ 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>
|
||||||
|
@ -80,12 +88,15 @@ namespace Jellyfin.Api.Controllers
|
||||||
/// </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>
|
||||||
|
/// <returns>Status.</returns>
|
||||||
[HttpPost("RemoteAccess")]
|
[HttpPost("RemoteAccess")]
|
||||||
public void SetRemoteAccess([FromForm] bool enableRemoteAccess, [FromForm] bool enableAutomaticPortMapping)
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
public IActionResult 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>
|
||||||
|
@ -93,14 +104,11 @@ namespace Jellyfin.Api.Controllers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The first user.</returns>
|
/// <returns>The first user.</returns>
|
||||||
[HttpGet("User")]
|
[HttpGet("User")]
|
||||||
public StartupUserDto GetFirstUser()
|
[ProducesResponseType(typeof(StartupUserDto), StatusCodes.Status200OK)]
|
||||||
|
public IActionResult GetFirstUser()
|
||||||
{
|
{
|
||||||
var user = _userManager.Users.First();
|
var user = _userManager.Users.First();
|
||||||
return new StartupUserDto
|
return Ok(new StartupUserDto { Name = user.Name, Password = user.Password });
|
||||||
{
|
|
||||||
Name = user.Name,
|
|
||||||
Password = user.Password
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -109,7 +117,8 @@ namespace Jellyfin.Api.Controllers
|
||||||
/// <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>
|
/// <returns>The async task.</returns>
|
||||||
[HttpPost("User")]
|
[HttpPost("User")]
|
||||||
public async Task UpdateUser([FromForm] StartupUserDto startupUserDto)
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
public async Task<IActionResult> UpdateUser([FromForm] StartupUserDto startupUserDto)
|
||||||
{
|
{
|
||||||
var user = _userManager.Users.First();
|
var user = _userManager.Users.First();
|
||||||
|
|
||||||
|
@ -121,6 +130,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 a new issue