event isSignedUp
This commit is contained in:
parent
f212f85d00
commit
787cdf5c6d
@ -41,5 +41,10 @@ namespace API.Authentication
|
||||
return _grantManager.hasGrant(user.permissionId, EventGrantNames.CanDeleteAny) ||
|
||||
_grantManager.getULongValues(user.permissionId, EventGrantNames.CanDelete).Exists(x => x == model.id);
|
||||
}
|
||||
public bool canCheckSelfSignup(User user)
|
||||
{
|
||||
//todo grants
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,5 +5,6 @@ namespace API.Authentication.Interfaces
|
||||
{
|
||||
public interface IEventAuthentication : IGenericAuthentication<EventDTO, Event>
|
||||
{
|
||||
bool canCheckSelfSignup(User user);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ namespace API.Controllers
|
||||
{
|
||||
}
|
||||
|
||||
//todo slow
|
||||
[HttpGet("period")]
|
||||
public virtual ActionResult<List<EventDTO>> getPeriod(DateTime start, DateTime end)
|
||||
{
|
||||
@ -30,7 +31,7 @@ namespace API.Controllers
|
||||
|
||||
List<EventDTO> dtos = [];
|
||||
|
||||
Parallel.ForEach(result, item =>
|
||||
Parallel.ForEach(result.ToList(), item =>
|
||||
{
|
||||
EventDTO dto = new EventDTO();
|
||||
dto.adaptFromModel(item);
|
||||
@ -39,5 +40,19 @@ namespace API.Controllers
|
||||
|
||||
return Ok(dtos);
|
||||
}
|
||||
|
||||
[HttpGet("{eventId}/isSignedUp")]
|
||||
public ActionResult<bool> isSignedUp(ulong eventId)
|
||||
{
|
||||
MUser? user = getUser(User);
|
||||
if (user == null)
|
||||
return Unauthorized();
|
||||
|
||||
bool? isSignedUp = Service.isSignedUp(user, eventId);
|
||||
if (isSignedUp == null)
|
||||
return Forbid();
|
||||
|
||||
return isSignedUp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,13 @@ namespace API.Services
|
||||
public EventService(ILogger<EventService> logger, SASGContext context, IEventAuthentication auth) : base(logger, context, auth)
|
||||
{
|
||||
}
|
||||
|
||||
public bool? isSignedUp(User user, ulong eventId)
|
||||
{
|
||||
if (!_auth.canCheckSelfSignup(user))
|
||||
return null;
|
||||
|
||||
return Context.Set<Signup>().Any(x => x.userId == user.id && x.eventId == eventId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user