...
 
Commits (3)
......@@ -9,8 +9,8 @@ using System.Reflection;
[assembly: AssemblyDescription("Project.Tests is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("Project.Tests")]
[assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: AssemblyInformationalVersion("1.5.0.0")]
[assembly: AssemblyVersion("1.5.1.0")]
[assembly: AssemblyFileVersion("1.5.1.0")]
[assembly: AssemblyInformationalVersion("1.5.1.0")]
[assembly: AssemblyCopyright("2019 IT Center, RWTH Aachen University")]
......@@ -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)
{
......
......@@ -9,8 +9,8 @@ using System.Reflection;
[assembly: AssemblyDescription("Project is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("Project")]
[assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: AssemblyInformationalVersion("1.5.0.0")]
[assembly: AssemblyVersion("1.5.1.0")]
[assembly: AssemblyFileVersion("1.5.1.0")]
[assembly: AssemblyInformationalVersion("1.5.1.0")]
[assembly: AssemblyCopyright("2019 IT Center, RWTH Aachen University")]