This commit is contained in:
@@ -53,8 +53,8 @@ namespace AyaNova.Api.Controllers
|
||||
[HttpGet("{logname}")]
|
||||
public ActionResult GetLog([FromRoute] string logname)
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
// if (serverState.IsClosed)
|
||||
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.LogFile))
|
||||
{
|
||||
@@ -93,8 +93,8 @@ namespace AyaNova.Api.Controllers
|
||||
[HttpGet()]
|
||||
public ActionResult ListLogs()
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
// if (serverState.IsClosed)
|
||||
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.LogFile))
|
||||
{
|
||||
@@ -126,8 +126,8 @@ namespace AyaNova.Api.Controllers
|
||||
[HttpGet("download/{logname}")]
|
||||
public async Task<IActionResult> DownloadLog([FromRoute] string logname, [FromQuery] string t)
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
// if (serverState.IsClosed)
|
||||
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
@@ -139,13 +139,13 @@ namespace AyaNova.Api.Controllers
|
||||
return StatusCode(401, new ApiErrorResponse(ApiErrorCode.AUTHENTICATION_FAILED));
|
||||
}
|
||||
|
||||
if (!Authorized.HasReadFullRole(user.Roles, AyaType.LogFile))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!Authorized.HasReadFullRole(user.Roles, AyaType.LogFile))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
var logFilePath = System.IO.Path.Combine(ServerBootConfig.AYANOVA_LOG_PATH, logname);
|
||||
if (!System.IO.File.Exists(logFilePath))
|
||||
var logFilePath = System.IO.Path.Combine(ServerBootConfig.AYANOVA_LOG_PATH, logname);
|
||||
if (!System.IO.File.Exists(logFilePath))
|
||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
|
||||
|
||||
return PhysicalFile(logFilePath, "text/plain", $"{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")}-{logname}");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user