fix: missing systemRef in patch /system, crash when system not found

This commit is contained in:
spiral 2021-12-01 08:43:16 -05:00
parent ab5484892f
commit a0d2773ef4
No known key found for this signature in database
GPG key ID: A6059F0CA0E1BD31
2 changed files with 12 additions and 3 deletions

View file

@ -81,6 +81,7 @@ public class SwitchControllerV2: PKControllerBase
public async Task<IActionResult> SwitchCreate(string systemRef, [FromBody] PostSwitchParams data)
{
var system = await ResolveSystem(systemRef);
if (system == null) throw Errors.SystemNotFound;
if (ContextFor(system) != LookupContext.ByOwner)
throw Errors.GenericMissingPermissions;
@ -163,6 +164,7 @@ public class SwitchControllerV2: PKControllerBase
// for now, don't need to make a PatchObject for this, since it's only one param
var system = await ResolveSystem(systemRef);
if (system == null) throw Errors.SystemNotFound;
if (ContextFor(system) != LookupContext.ByOwner)
throw Errors.GenericMissingPermissions;
@ -197,6 +199,7 @@ public class SwitchControllerV2: PKControllerBase
public async Task<IActionResult> SwitchMemberPatch(string systemRef, string switchRef, [FromBody] JArray data)
{
var system = await ResolveSystem(systemRef);
if (system == null) throw Errors.SystemNotFound;
if (ContextFor(system) != LookupContext.ByOwner)
throw Errors.GenericMissingPermissions;
@ -244,6 +247,7 @@ public class SwitchControllerV2: PKControllerBase
public async Task<IActionResult> SwitchDelete(string systemRef, string switchRef)
{
var system = await ResolveSystem(systemRef);
if (system == null) throw Errors.SystemNotFound;
if (ContextFor(system) != LookupContext.ByOwner)
throw Errors.GenericMissingPermissions;