diff options
| author | JPVenson <github@jpb.email> | 2025-02-05 18:32:13 +0000 |
|---|---|---|
| committer | JPVenson <github@jpb.email> | 2025-02-05 18:32:13 +0000 |
| commit | dfdef511a5b855ee4e4f079236ff43cb508958d5 (patch) | |
| tree | db2c5d8cfe13817b165c1d24495947d98c25f670 /Jellyfin.Api/Auth/CustomAuthenticationHandler.cs | |
| parent | 078587d232ccbfdf6e08c6f1a6435e4e397e4bdc (diff) | |
| parent | 00b66a06eac4d1331d59a6a9b7de3e99088ebaa9 (diff) | |
Merge remote-tracking branch 'jellyfinorigin/master' into feature/pgsql_provider
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 228413777..0fd014990 100644 --- a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs +++ b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs @@ -51,20 +51,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)) }; |
