api validation implemented
This commit is contained in:
parent
645f28c7d8
commit
5ee5f70c6d
@ -282,6 +282,26 @@ public class ApiController(
|
||||
if (!ModelState.IsValid)
|
||||
return ValidationErrorResult(ModelState);
|
||||
|
||||
try
|
||||
{
|
||||
var identifier = await buildService.FetchIdentifierFromCsprojAsync(
|
||||
model.GitRepository,
|
||||
model.GitRef,
|
||||
model.PluginDirectory);
|
||||
|
||||
var owns = await conn.EnsureIdentifierOwnership(pluginSlug, identifier);
|
||||
if (!owns)
|
||||
{
|
||||
ModelState.AddModelError(string.Empty, $"The plugin identifier {identifier} does not belong to plugin slug {pluginSlug}.");
|
||||
return ValidationErrorResult(ModelState);
|
||||
}
|
||||
}
|
||||
catch (BuildServiceException ex)
|
||||
{
|
||||
ModelState.AddModelError(string.Empty, $"Manifest validation failed: {ex.Message}");
|
||||
return ValidationErrorResult(ModelState);
|
||||
}
|
||||
|
||||
var buildId = await conn.NewBuild(pluginSlug, model.ToBuildParameter());
|
||||
var buildUrl = Url.ActionLink(nameof(PluginController.Build), "Plugin",
|
||||
new { pluginSlug = pluginSlug.ToString(), buildId });
|
||||
|
||||
Loading…
Reference in New Issue
Block a user