Skip to content

Commit

Permalink
fix: Reject pending table registrations when a new registration is ma…
Browse files Browse the repository at this point in the history
…de (#159)

* fix: Reject pending table registrations when a new registration is made

* fix: Remove AsNoTracking()
  • Loading branch information
Rain336 authored Aug 17, 2024
1 parent b801856 commit 8f28d9a
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ public override async Task<TableRegistrationRecord> FindOneAsync(

public async Task RegisterTableAsync(ClaimsPrincipal user, TableRegistrationRequest request)
{
var subject = user.GetSubject();
var activeRegistrations = await _appDbContext.TableRegistrations
.Where(x =>
x.OwnerUid == subject &&
x.State == TableRegistrationRecord.RegistrationStateEnum.Pending)
.ToListAsync();

foreach (var registration in activeRegistrations)
{
registration.ChangeState(TableRegistrationRecord.RegistrationStateEnum.Rejected, subject);
registration.Touch();
}

var image = await _imageService.FindOneAsync(request.ImageId);

await _imageService.EnforceMaximumDimensionsAsync(image, 1500, 1500);
Expand Down

0 comments on commit 8f28d9a

Please sign in to comment.