Commit 23255af4 authored by Benedikt Heinrichs's avatar Benedikt Heinrichs

Fix: Datasource connection now working on release builds (coscine/issues#380)

parent 7346cd89
......@@ -94,7 +94,7 @@ namespace Coscine.Api.Project.Controllers
}
else
{
return FailedRequeset(response, path);
return FailedRequest(response, path);
}
}
}
......@@ -137,15 +137,13 @@ namespace Coscine.Api.Project.Controllers
}
else
{
return FailedRequeset(response, path);
return FailedRequest(response, path);
}
}
catch (Exception e)
{
Console.WriteLine(e);
return BadRequest(e);
}
}
}
......@@ -188,15 +186,13 @@ namespace Coscine.Api.Project.Controllers
}
else
{
return FailedRequeset(response, path);
return FailedRequest(response, path);
}
}
catch (Exception e)
{
Console.WriteLine(e);
return BadRequest(e);
}
}
}
......@@ -248,26 +244,24 @@ namespace Coscine.Api.Project.Controllers
}
else
{
return FailedRequeset(response, path);
return FailedRequest(response, path);
}
}
catch (Exception e)
{
Console.WriteLine(e);
return BadRequest(e);
}
}
}
private IActionResult FailedRequeset(HttpResponseMessage response, string path)
private IActionResult FailedRequest(HttpResponseMessage response, string path)
{
if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
{
return NotFound($"Could not find object for: \"{path}\".");
}
else
if (response.StatusCode == System.Net.HttpStatusCode.Forbidden)
else if (response.StatusCode == System.Net.HttpStatusCode.Forbidden)
{
return Forbid("Not allowed to access the datasource.");
}
......@@ -292,25 +286,23 @@ namespace Coscine.Api.Project.Controllers
return BadRequest($"Your path \"{path}\" contains bad chars. Only {@"^[0-9a-zA-Z_\-./ ]+"} are allowed as chars.");
}
if (!Guid.TryParse(resourceId, out Guid resouceGuid))
if (!Guid.TryParse(resourceId, out Guid resourceGuid))
{
return BadRequest($"{resourceId} is not a guid.");
}
#if! DEBUG
var user = _authenticator.GetUserFromToken();
if (!_resourceModel.OwnsResource(user, resource))
{
return Forbid($"The user does not own the resource {resourceId}");
}
#endif
try
{
resource = _resourceModel.GetById(resouceGuid);
resource = _resourceModel.GetById(resourceGuid);
if (resource == null)
{
return NotFound($"Could not find resource with id: {resourceId}");
}
var user = _authenticator.GetUserFromToken();
if (!_resourceModel.OwnsResource(user, resource))
{
return Forbid($"The user does not own the resource {resourceId}");
}
}
catch (Exception)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment