This commit is contained in:
@@ -61,6 +61,9 @@ namespace AyaNova.Api.Controllers
|
|||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
|
||||||
var result = await EventLogProcessor.GetLogForObjectAsync(opt, ct);
|
var result = await EventLogProcessor.GetLogForObjectAsync(opt, ct);
|
||||||
return Ok(ApiOkResponse.Response(result, true));
|
return Ok(ApiOkResponse.Response(result, true));
|
||||||
}
|
}
|
||||||
@@ -80,16 +83,13 @@ namespace AyaNova.Api.Controllers
|
|||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
|
||||||
if (opt.AyType != AyaType.User)
|
if (!ModelState.IsValid)
|
||||||
{
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
//return bad request
|
|
||||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, "AyType", "User type required"));
|
|
||||||
}
|
|
||||||
|
|
||||||
long UserId = UserIdFromContext.Id(HttpContext.Items);
|
long UserId = UserIdFromContext.Id(HttpContext.Items);
|
||||||
|
|
||||||
//If not authorized to read a user and also not the current user asking for their own log then NO LOG FOR YOU!
|
//If not authorized to read a user and also not the current user asking for their own log then NO LOG FOR YOU!
|
||||||
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.User) && opt.AyId != UserId)
|
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.User) && opt.UserId != UserId)
|
||||||
{
|
{
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
{
|
{
|
||||||
|
|
||||||
[FromQuery]
|
[FromQuery]
|
||||||
public long AyId { get; set; }
|
public long UserId { get; set; }
|
||||||
[FromQuery]
|
[FromQuery]
|
||||||
public int? Offset { get; set; }
|
public int? Offset { get; set; }
|
||||||
[FromQuery]
|
[FromQuery]
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace AyaNova.Biz
|
|||||||
//Set up the query
|
//Set up the query
|
||||||
var q = ct.Event.Select(m => m);
|
var q = ct.Event.Select(m => m);
|
||||||
|
|
||||||
q = q.Where(m => m.UserId == opt.AyId);
|
q = q.Where(m => m.UserId == opt.UserId);
|
||||||
var limit = opt.Limit ?? 100;
|
var limit = opt.Limit ?? 100;
|
||||||
var offset = opt.Offset ?? 0;
|
var offset = opt.Offset ?? 0;
|
||||||
q = q.OrderBy(m => m.Created);
|
q = q.OrderBy(m => m.Created);
|
||||||
|
|||||||
Reference in New Issue
Block a user