Skip to content
Snippets Groups Projects
Commit a1e55f71 authored by Petar Hristov's avatar Petar Hristov :speech_balloon:
Browse files

Merge branch 'Issue/2355-topLevelOrg' into 'dev'

Fix: Allowing only top-level organizations under participating organizations

See merge request !242
parents 05e877f2 7f2b06d8
No related branches found
No related tags found
2 merge requests!244Release: Sprint/2023 05 :robot:,!242Fix: Allowing only top-level organizations under participating organizations
...@@ -367,13 +367,23 @@ namespace Coscine.Api.Project.Controllers ...@@ -367,13 +367,23 @@ namespace Coscine.Api.Project.Controllers
} }
/// <summary> /// <summary>
/// Creates a project /// Creates a new project
/// </summary> /// </summary>
/// <param name="projectObject">A Project Object</param> /// <param name="projectObject">The project to create.</param>
/// <returns>JSON object or status code 401</returns> /// <returns>A JSON representation of the created project.</returns>
/// <response code="200">The project was created successfully.</response>
/// <response code="401">The user does not have sufficient permissions to create a project.</response>
/// <response code="422">The project object is invalid or contains invalid data.</response>
[HttpPost("[controller]")] [HttpPost("[controller]")]
public IActionResult Store([FromBody] ProjectObject projectObject) public IActionResult Store([FromBody] ProjectObject projectObject)
{ {
// ------
// This is the wrong place to do that, but we have to live with it. For the APIv2 consider moving that to a validation attribute.
// Also consider using the following Regex:
// (http|https):\/\/ror\.org\/[a-zA-Z0-9]+
if (projectObject.Organizations.Any(o => o.Url.Contains('#')))
return UnprocessableEntity("The URL of the organization cannot contain the '#' character. Only top-level organizations are allowed.");
// ------
var user = _authenticator.GetUser(); var user = _authenticator.GetUser();
// Rights Matrix (https://git.rwth-aachen.de/coscine/docs/private/internal-wiki/-/blob/master/coscine/Definition%20of%20rights%20Matrix.md) // Rights Matrix (https://git.rwth-aachen.de/coscine/docs/private/internal-wiki/-/blob/master/coscine/Definition%20of%20rights%20Matrix.md)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment