Skip to content

Commit 180bf89

Browse files
committed
Make protected accounts more clear
1 parent dc6d037 commit 180bf89

File tree

2 files changed

+58
-9
lines changed

2 files changed

+58
-9
lines changed

ReplayBrowser/Helpers/ReplayHelper.cs

+57-8
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,27 @@ public async Task<List<Replay>> GetMostRecentReplays(AuthenticationState state)
7070
throw new UnauthorizedAccessException("This account is protected by a GDPR request. There is no data available.");
7171
}
7272

73-
var accountRequested = _accountService.GetAccountSettings(playerGuid);
73+
var accountRequested = _context.Accounts
74+
.Include(a => a.Settings)
75+
.FirstOrDefault(a => a.Guid == playerGuid);
7476

7577
if (!skipPermsCheck)
7678
{
77-
if (accountRequested is { RedactInformation: true })
79+
if (accountRequested is { Settings.RedactInformation: true })
7880
{
7981
if (accountCaller == null || !accountCaller.IsAdmin)
8082
{
8183
if (accountCaller?.Guid != playerGuid)
8284
{
83-
throw new UnauthorizedAccessException("The account you are trying to view is private. Contact the account owner and ask them to make their account public.");
85+
if (accountRequested.Protected)
86+
{
87+
throw new UnauthorizedAccessException("This account is protected and redacted. This might happens due to harassment or other reasons.");
88+
}
89+
else
90+
{
91+
throw new UnauthorizedAccessException(
92+
"The account you are trying to view is private. Contact the account owner and ask them to make their account public.");
93+
}
8494
}
8595
}
8696
}
@@ -348,13 +358,28 @@ public async Task<SearchResult> SearchReplays(List<SearchQueryItem> searchItems,
348358
{
349359
if (callerAccount == null || !callerAccount.IsAdmin)
350360
{
351-
throw new UnauthorizedAccessException("The account you are trying to search for is private. Contact the account owner and ask them to make their account public.");
361+
if (foundOocAccount.Protected)
362+
{
363+
throw new UnauthorizedAccessException("This account is protected and redacted. This might happens due to harassment or other reasons.");
364+
}
365+
else
366+
{
367+
throw new UnauthorizedAccessException("The account you are trying to search for is private. Contact the account owner and ask them to make their account public.");
368+
}
352369
}
353370
}
354371
}
355372
} else if (foundOocAccount != null && foundOocAccount.Settings.RedactInformation)
356373
{
357-
throw new UnauthorizedAccessException("The account you are trying to search for is private. Contact the account owner and ask them to make their account public.");
374+
if (foundOocAccount.Protected)
375+
{
376+
throw new UnauthorizedAccessException("This account is protected and redacted. This might happens due to harassment or other reasons.");
377+
}
378+
else
379+
{
380+
throw new UnauthorizedAccessException(
381+
"The account you are trying to search for is private. Contact the account owner and ask them to make their account public.");
382+
}
358383
}
359384
}
360385

@@ -375,16 +400,40 @@ public async Task<SearchResult> SearchReplays(List<SearchQueryItem> searchItems,
375400
// if the requestor is not the found account and the requestor is not an admin, deny access
376401
if (callerAccount == null || !callerAccount.IsAdmin)
377402
{
378-
throw new UnauthorizedAccessException("The account you are trying to search for is private. Contact the account owner and ask them to make their account public.");
403+
if (foundGuidAccount.Protected)
404+
{
405+
throw new UnauthorizedAccessException("This account is protected and redacted. This might happens due to harassment or other reasons.");
406+
}
407+
else
408+
{
409+
throw new UnauthorizedAccessException(
410+
"The account you are trying to search for is private. Contact the account owner and ask them to make their account public.");
411+
}
379412
}
380413
}
381414
} else
382415
{
383-
throw new UnauthorizedAccessException("The account you are trying to search for is private. Contact the account owner and ask them to make their account public.");
416+
if (foundGuidAccount.Protected)
417+
{
418+
throw new UnauthorizedAccessException("This account is protected and redacted. This might happens due to harassment or other reasons.");
419+
}
420+
else
421+
{
422+
throw new UnauthorizedAccessException(
423+
"The account you are trying to search for is private. Contact the account owner and ask them to make their account public.");
424+
}
384425
}
385426
} else if (foundGuidAccount != null && foundGuidAccount.Settings.RedactInformation)
386427
{
387-
throw new UnauthorizedAccessException("The account you are trying to search for is private. Contact the account owner and ask them to make their account public.");
428+
if (foundGuidAccount.Protected)
429+
{
430+
throw new UnauthorizedAccessException("This account is protected and redacted. This might happens due to harassment or other reasons.");
431+
}
432+
else
433+
{
434+
throw new UnauthorizedAccessException(
435+
"The account you are trying to search for is private. Contact the account owner and ask them to make their account public.");
436+
}
388437
}
389438
}
390439

ReplayBrowser/Pages/Search.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@
222222
}
223223
catch (UnauthorizedAccessException e)
224224
{
225-
ErrorMessage = "The account you are trying to search for is private. Contact the account owner and ask them to make their account public.";
225+
ErrorMessage = "Redacted account(s).";
226226
ErrorDetails = e.Message;
227227
stopWatch.Stop();
228228
return;

0 commit comments

Comments
 (0)