Skip to content

Commit

Permalink
Add Check for Revoked Participants
Browse files Browse the repository at this point in the history
  • Loading branch information
TheR00st3r committed Nov 12, 2024
1 parent 8a4eb25 commit 57628ba
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
4 changes: 3 additions & 1 deletion Models/Ticket.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using EventulaEntranceClient.Converter;
using EventulaEntranceClient.Storage;
using LiteDB;
using System.Text.Json.Serialization;

Expand Down Expand Up @@ -86,6 +85,9 @@ public class Participant : IStoreObject

[JsonPropertyName("seat")]
public Seat Seat { get; set; }

[JsonPropertyName("revoked")]
public bool Revoked { get; set; }
}

public class User
Expand Down
1 change: 1 addition & 0 deletions Pages/Management.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<div class="@AnimationClass" onmousemove="@(() => ResetTimerInterval())" onkeypress="@(() => ResetTimerInterval())">

<audio id="newParticipantSound" src="/audio/mixkit-elevator-tone-2863.wav" />
<audio id="revokedParticipantSound" src="/audio/mixkit-arcade-space-shooter-dead-notification-272.wav" />

<div class="row">
<div class="col-8 col-md-9 col-lg-10">
Expand Down
9 changes: 8 additions & 1 deletion Pages/Management.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,14 @@ public async Task ProcessImage(string imageString)
var ticketRequest = await _EventulaApiService.RequestTicket(qrCode).ConfigureAwait(false);
if (ticketRequest?.Participant != null)
{
await AddParticipantAsync(ticketRequest.Participant).ConfigureAwait(false);
if(ticketRequest.Participant.Revoked)
{
await _JSRuntime.InvokeAsync<string>("PlayAudio", "revokedParticipantSound");
}
else
{
await AddParticipantAsync(ticketRequest.Participant).ConfigureAwait(false);
}
}
}
}
Expand Down
17 changes: 10 additions & 7 deletions Services/EventulaApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,12 @@ private async Task SetXcsrfHeader(HttpClient httpClient)
{
var csrfCookieUrl = new Uri(httpClient.BaseAddress, _CsrfCookieUrl);


var csrfCookies = _Cookies.GetCookies(csrfCookieUrl);

var csrfToken = csrfCookies.FirstOrDefault(x => x.Name.Equals("XSRF-TOKEN", StringComparison.Ordinal));
var csrfToken = GetCsrfToken(csrfCookieUrl);

if (csrfToken == null)
{
var getCsrfResult = await httpClient.GetAsync(_CsrfCookieUrl);
csrfCookies = _Cookies.GetCookies(csrfCookieUrl);
csrfToken = csrfCookies.FirstOrDefault(x => x.Name.Equals("XSRF-TOKEN", StringComparison.Ordinal));
await httpClient.GetAsync(_CsrfCookieUrl);
csrfToken = GetCsrfToken(csrfCookieUrl);
}

if (csrfToken != null)
Expand All @@ -107,6 +103,13 @@ private async Task SetXcsrfHeader(HttpClient httpClient)
}
}

private Cookie GetCsrfToken(Uri csrfCookieUrl)
{
var csrfCookies = _Cookies.GetCookies(csrfCookieUrl);
var csrfToken = csrfCookies.FirstOrDefault(x => x.Name.Equals("XSRF-TOKEN", StringComparison.Ordinal));
return csrfToken;
}

private static void SetDefaultHeaders(HttpClient httpClient, string token)
{
var requestToken = token.Split('|').Last();
Expand Down
Binary file not shown.

0 comments on commit 57628ba

Please sign in to comment.