Refactor and Test Application Controller and ApiKey Access Authorization Handling ...
This commit is contained in:
@@ -90,14 +90,16 @@ namespace xIds.Controllers
|
||||
/// }
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("")]
|
||||
[HttpPut("{id}")]
|
||||
[RequireXPowered]
|
||||
[Authorize(LocalApi.PolicyName)]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<XApplicationDto>> UpdateApplication(
|
||||
[FromRoute] int id,
|
||||
[FromBody] XApplicationDto item,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
@@ -107,7 +109,10 @@ namespace xIds.Controllers
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!item.IsValidForAdd())
|
||||
if (!id.IsValidIntId() ||
|
||||
!item.IsValidForAdd() ||
|
||||
id != item.Id
|
||||
)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
@@ -117,8 +122,8 @@ namespace xIds.Controllers
|
||||
|
||||
//
|
||||
var result = await provider.UpdateApplicationAsync(
|
||||
id: id,
|
||||
item: item,
|
||||
id: item.Id,
|
||||
userInfo: userInfo,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user