diff options
| author | Patrick Barron <barronpm@gmail.com> | 2020-04-05 14:44:14 -0400 |
|---|---|---|
| committer | Patrick Barron <barronpm@gmail.com> | 2020-04-05 14:44:14 -0400 |
| commit | add0a2088de154137cf547f84c85f59a78e442d8 (patch) | |
| tree | dfd0b6a6bab67db2d4b3784b487ac0bc5a5bcd8d /MediaBrowser.Api/BaseApiService.cs | |
| parent | 80cfcf5643b50fd1acfdc82cae849948a39233b9 (diff) | |
Simplified Conditionals and returns
Diffstat (limited to 'MediaBrowser.Api/BaseApiService.cs')
| -rw-r--r-- | MediaBrowser.Api/BaseApiService.cs | 24 |
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."); } } |
