|
|
@ -26,7 +26,7 @@ public class TacticController(ITacticService service, IContextAccessor accessor)
|
|
|
|
[FromBody] UpdateNameRequest req)
|
|
|
|
[FromBody] UpdateNameRequest req)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var userId = accessor.CurrentUserId(HttpContext);
|
|
|
|
var userId = accessor.CurrentUserId(HttpContext);
|
|
|
|
if (!await service.HasAnyRights(userId, tacticId))
|
|
|
|
if (!await service.IsOwnerOf(userId, tacticId))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Unauthorized();
|
|
|
|
return Unauthorized();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -41,7 +41,7 @@ public class TacticController(ITacticService service, IContextAccessor accessor)
|
|
|
|
public async Task<IActionResult> GetTacticInfo(int tacticId)
|
|
|
|
public async Task<IActionResult> GetTacticInfo(int tacticId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var userId = accessor.CurrentUserId(HttpContext);
|
|
|
|
var userId = accessor.CurrentUserId(HttpContext);
|
|
|
|
if (!await service.HasAnyRights(userId, tacticId))
|
|
|
|
if (!await service.IsOwnerOf(userId, tacticId))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Unauthorized();
|
|
|
|
return Unauthorized();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -57,7 +57,7 @@ public class TacticController(ITacticService service, IContextAccessor accessor)
|
|
|
|
public async Task<IActionResult> GetTacticStepsRoot(int tacticId)
|
|
|
|
public async Task<IActionResult> GetTacticStepsRoot(int tacticId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var userId = accessor.CurrentUserId(HttpContext);
|
|
|
|
var userId = accessor.CurrentUserId(HttpContext);
|
|
|
|
if (!await service.HasAnyRights(userId, tacticId))
|
|
|
|
if (!await service.IsOwnerOf(userId, tacticId))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Unauthorized();
|
|
|
|
return Unauthorized();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -110,7 +110,7 @@ public class TacticController(ITacticService service, IContextAccessor accessor)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var userId = accessor.CurrentUserId(HttpContext);
|
|
|
|
var userId = accessor.CurrentUserId(HttpContext);
|
|
|
|
|
|
|
|
|
|
|
|
if (!await service.HasAnyRights(userId, tacticId))
|
|
|
|
if (!await service.IsOwnerOf(userId, tacticId))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Unauthorized();
|
|
|
|
return Unauthorized();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -125,7 +125,7 @@ public class TacticController(ITacticService service, IContextAccessor accessor)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var userId = accessor.CurrentUserId(HttpContext);
|
|
|
|
var userId = accessor.CurrentUserId(HttpContext);
|
|
|
|
|
|
|
|
|
|
|
|
if (!await service.HasAnyRights(userId, tacticId))
|
|
|
|
if (!await service.IsOwnerOf(userId, tacticId))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Unauthorized();
|
|
|
|
return Unauthorized();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -142,7 +142,7 @@ public class TacticController(ITacticService service, IContextAccessor accessor)
|
|
|
|
public async Task<IActionResult> SaveStepContent(int tacticId, int stepId, [FromBody] SaveStepContentRequest req)
|
|
|
|
public async Task<IActionResult> SaveStepContent(int tacticId, int stepId, [FromBody] SaveStepContentRequest req)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var userId = accessor.CurrentUserId(HttpContext);
|
|
|
|
var userId = accessor.CurrentUserId(HttpContext);
|
|
|
|
if (!await service.HasAnyRights(userId, tacticId))
|
|
|
|
if (!await service.IsOwnerOf(userId, tacticId))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Unauthorized();
|
|
|
|
return Unauthorized();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -150,5 +150,14 @@ public class TacticController(ITacticService service, IContextAccessor accessor)
|
|
|
|
var found = await service.SetTacticStepContent(tacticId, stepId, JsonSerializer.Serialize(req.Content));
|
|
|
|
var found = await service.SetTacticStepContent(tacticId, stepId, JsonSerializer.Serialize(req.Content));
|
|
|
|
return found ? Ok() : NotFound();
|
|
|
|
return found ? Ok() : NotFound();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public record CanEditResponse(bool CanEdit);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet("/tactics/{tacticId:int}/can-edit")]
|
|
|
|
|
|
|
|
[Authorize]
|
|
|
|
|
|
|
|
public async Task<CanEditResponse> CanEdit(int tacticId)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var userId = accessor.CurrentUserId(HttpContext);
|
|
|
|
|
|
|
|
return new CanEditResponse(await service.IsOwnerOf(userId, tacticId));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|