Skip to content

Commit

Permalink
Clarify that the regrade permission also applies to reranking games
Browse files Browse the repository at this point in the history
  • Loading branch information
sei-bstein committed Nov 15, 2024
1 parent 9fbd386 commit 75789b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Gameboard.Api.Common.Services;
Expand Down Expand Up @@ -107,8 +108,8 @@ internal class UserRolePermissionsService(IActingUserService actingUserService,
{
Group = PermissionKeyGroup.Scoring,
Key = PermissionKey.Scores_RegradeAndRerank,
Name = "Regrade challenges",
Description = "Manually initiate regrading of challenges"
Name = "Revise scores",
Description = "Manually initiate reranking of games and regrading of challenges"
},
new()
{
Expand Down
20 changes: 11 additions & 9 deletions src/Gameboard.Api/Structure/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,30 +122,30 @@ public class SecurityHeaderOptions
public class CorsPolicyOptions
{
public string Name { get; set; } = "default";
public string[] Origins { get; set; } = Array.Empty<string>();
public string[] Methods { get; set; } = Array.Empty<string>();
public string[] Headers { get; set; } = Array.Empty<string>();
public string[] Origins { get; set; } = [];
public string[] Methods { get; set; } = [];
public string[] Headers { get; set; } = [];
public bool AllowCredentials { get; set; }

public CorsPolicy Build()
{
var policy = new CorsPolicyBuilder();

var origins = Origins.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
if (origins.Any())
if (origins.Length > 0)
{
if (origins.First() == "*") policy.AllowAnyOrigin(); else policy.WithOrigins(origins);
if (AllowCredentials && origins.First() != "*") policy.AllowCredentials(); else policy.DisallowCredentials();
}

var methods = Methods.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
if (methods.Any())
if (methods.Length > 0)
{
if (methods.First() == "*") policy.AllowAnyMethod(); else policy.WithMethods(methods);
}

var headers = Headers.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
if (headers.Any())
if (headers.Length > 0)
{
if (headers.First() == "*") policy.AllowAnyHeader(); else policy.WithHeaders(headers);
}
Expand Down Expand Up @@ -220,9 +220,11 @@ public static DateTimeOffset[][] GetShifts(string[][] shiftStrings)
// Create a new DateTimeOffset representation for every string time given
for (int i = 0; i < shiftStrings.Length; i++)
{
offsets[i] = new DateTimeOffset[] {
ConvertTime(shiftStrings[i][0], ShiftTimezoneFallback),
ConvertTime(shiftStrings[i][1], ShiftTimezoneFallback) };
offsets[i] =
[
ConvertTime(shiftStrings[i][0], ShiftTimezoneFallback),
ConvertTime(shiftStrings[i][1], ShiftTimezoneFallback)
];
}
return offsets;
}
Expand Down

0 comments on commit 75789b0

Please sign in to comment.