Skip to content

Commit

Permalink
email only in authenticated requests
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-garcia committed Mar 24, 2024
1 parent f177078 commit 1b89ad9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Sentaur.Leaderboard.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@
{
return context.ScoreEntries
.OrderByDescending(p => p.Score)
.Select(p => new {
p.Key,
p.Name,
p.Score,
p.Duration,
p.Timestamp
})
.ToListAsync(token);
})
.WithName("scores")
Expand Down Expand Up @@ -132,7 +139,7 @@
return Results.Problem($"Failed to remove provided entry with name '{name}' and score '{score}'");
});

app.MapGet("/lottery", [AllowAnonymous] async (LeaderboardContext context, CancellationToken token) =>
app.MapGet("/lottery", [Authorize] async (LeaderboardContext context, CancellationToken token) =>
{
var allResults = await LotteryEntries(context, token);
var winner = Random.Shared.GetItems(allResults.ToArray(), 1);
Expand All @@ -142,7 +149,10 @@
.WithOpenApi();


app.MapGet("/lottery/entries", LotteryEntries)
app.MapGet("/lottery/entries", [Authorize] (LeaderboardContext context, CancellationToken token) =>
{
return LotteryEntries(context, token);
})
.WithName("lottery-entries")
.WithOpenApi();

Expand Down

0 comments on commit 1b89ad9

Please sign in to comment.