aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/BaseApiService.cs
diff options
context:
space:
mode:
authorPatrick Barron <barronpm@gmail.com>2020-04-05 14:44:14 -0400
committerPatrick Barron <barronpm@gmail.com>2020-04-05 14:44:14 -0400
commitadd0a2088de154137cf547f84c85f59a78e442d8 (patch)
treedfd0b6a6bab67db2d4b3784b487ac0bc5a5bcd8d /MediaBrowser.Api/BaseApiService.cs
parent80cfcf5643b50fd1acfdc82cae849948a39233b9 (diff)
Simplified Conditionals and returns
Diffstat (limited to 'MediaBrowser.Api/BaseApiService.cs')
-rw-r--r--MediaBrowser.Api/BaseApiService.cs24
1 files changed, 6 insertions, 18 deletions
diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs
index 0312cc57e..b43aed7bf 100644
--- a/MediaBrowser.Api/BaseApiService.cs
+++ b/MediaBrowser.Api/BaseApiService.cs
@@ -58,12 +58,9 @@ namespace MediaBrowser.Api
public static string[] SplitValue(string value, char delim)
{
- if (value == null)
- {
- return Array.Empty<string>();
- }
-
- return value.Split(new[] { delim }, StringSplitOptions.RemoveEmptyEntries);
+ return value == null
+ ? Array.Empty<string>()
+ : value.Split(new[] { delim }, StringSplitOptions.RemoveEmptyEntries);
}
public static Guid[] GetGuids(string value)
@@ -97,19 +94,10 @@ namespace MediaBrowser.Api
var authenticatedUser = auth.User;
// If they're going to update the record of another user, they must be an administrator
- if (!userId.Equals(auth.UserId))
- {
- if (!authenticatedUser.Policy.IsAdministrator)
- {
- throw new SecurityException("Unauthorized access.");
- }
- }
- else if (restrictUserPreferences)
+ if ((!userId.Equals(auth.UserId) && !authenticatedUser.Policy.IsAdministrator)
+ || (restrictUserPreferences && !authenticatedUser.Policy.EnableUserPreferenceAccess))
{
- if (!authenticatedUser.Policy.EnableUserPreferenceAccess)
- {
- throw new SecurityException("Unauthorized access.");
- }
+ throw new SecurityException("Unauthorized access.");
}
}