Skip to content

Commit 085e66e

Browse files
committed
Fix some redaction issues
1 parent 684f099 commit 085e66e

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

ReplayBrowser/Helpers/ReplayHelper.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ public async Task<int> GetTotalReplayCount()
248248

249249
private Replay FilterReplay(Replay replay, Account? caller = null)
250250
{
251+
if (replay.RoundEndPlayers == null)
252+
return replay;
253+
251254
foreach (var replayRoundEndPlayer in replay.RoundEndPlayers)
252255
{
253256
var accountForPlayer = _accountService.GetAccountSettings(replayRoundEndPlayer.PlayerGuid);

ReplayBrowser/Services/AccountService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ public async Task UpdateAccount(Account? account)
180180
using var scope = _scopeFactory.CreateScope();
181181
var context = scope.ServiceProvider.GetRequiredService<ReplayDbContext>();
182182
context.Accounts.Update(account);
183+
GenerateAccountSettings();
183184
await context.SaveChangesAsync();
184185
}
185186

ReplayBrowser/Services/LeaderboardService.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,23 @@ public async Task<LeaderboardData> GetLeaderboard(RangeOption rangeOption, strin
152152
});
153153
}
154154

155-
if (username != null && accountCaller != null)
155+
if (username != null)
156156
{
157157
var accountRequested = await context.Accounts
158158
.Include(a => a.Settings)
159159
.FirstOrDefaultAsync(a => a.Username.ToLower() == username.ToLower());
160160

161-
if (accountRequested != null && accountRequested.Settings.RedactInformation &&
162-
(accountCaller == null || accountCaller.Guid != accountRequested.Guid))
161+
if (accountRequested != null)
163162
{
164-
if (accountCaller == null || !accountCaller.IsAdmin)
163+
if (accountRequested.Settings.RedactInformation)
165164
{
166-
throw new UnauthorizedAccessException("This user has chosen to privatize their information.");
165+
if (accountRequested.Id != accountCaller?.Id)
166+
{
167+
if (accountCaller is not { IsAdmin: true })
168+
{
169+
throw new UnauthorizedAccessException("This user has chosen to privatize their information.");
170+
}
171+
}
167172
}
168173
}
169174
}

0 commit comments

Comments
 (0)