diff options
| author | Bond-009 <bond.009@outlook.com> | 2025-02-05 01:10:39 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-04 17:10:39 -0700 |
| commit | 00b66a06eac4d1331d59a6a9b7de3e99088ebaa9 (patch) | |
| tree | d97628d72afa37d4e9a314117f697c035485a94c /Jellyfin.Api/Auth/CustomAuthenticationHandler.cs | |
| parent | 2de04cb07c3b5f02fb5d5d9892541614e990cbe0 (diff) | |
Enable nullable for AuthorizationInfo (#13485)
Diffstat (limited to 'Jellyfin.Api/Auth/CustomAuthenticationHandler.cs')
| -rw-r--r-- | Jellyfin.Api/Auth/CustomAuthenticationHandler.cs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs index c2398f71b..1286c92c7 100644 --- a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs +++ b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs @@ -50,20 +50,21 @@ namespace Jellyfin.Api.Auth } var role = UserRoles.User; - if (authorizationInfo.IsApiKey || authorizationInfo.User.HasPermission(PermissionKind.IsAdministrator)) + if (authorizationInfo.IsApiKey + || (authorizationInfo.User?.HasPermission(PermissionKind.IsAdministrator) ?? false)) { role = UserRoles.Administrator; } var claims = new[] { - new Claim(ClaimTypes.Name, authorizationInfo.User.Username), + new Claim(ClaimTypes.Name, authorizationInfo.User?.Username ?? string.Empty), new Claim(ClaimTypes.Role, role), new Claim(InternalClaimTypes.UserId, authorizationInfo.UserId.ToString("N", CultureInfo.InvariantCulture)), - new Claim(InternalClaimTypes.DeviceId, authorizationInfo.DeviceId), - new Claim(InternalClaimTypes.Device, authorizationInfo.Device), - new Claim(InternalClaimTypes.Client, authorizationInfo.Client), - new Claim(InternalClaimTypes.Version, authorizationInfo.Version), + new Claim(InternalClaimTypes.DeviceId, authorizationInfo.DeviceId ?? string.Empty), + new Claim(InternalClaimTypes.Device, authorizationInfo.Device ?? string.Empty), + new Claim(InternalClaimTypes.Client, authorizationInfo.Client ?? string.Empty), + new Claim(InternalClaimTypes.Version, authorizationInfo.Version ?? string.Empty), new Claim(InternalClaimTypes.Token, authorizationInfo.Token), new Claim(InternalClaimTypes.IsApiKey, authorizationInfo.IsApiKey.ToString(CultureInfo.InvariantCulture)) }; |
