Skip to content

Commit c876d84

Browse files
committed
fix null error from build
1 parent a4f89b6 commit c876d84

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/CZ.AspNetCore.EasyAuthAuthentication/Services/EasyAuthForAuthorizationTokenService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private IEnumerable<AADClaimsModel> BuildFromAuthToken(JObject xMsClientPrincipa
7676
{
7777
this.logger.LogDebug($"payload was {xMsClientPrincipal[this.defaultOptions.RoleClaimType]}");
7878

79-
claims.AddRange(JsonConvert.DeserializeObject<IEnumerable<string>>(xMsClientPrincipal[this.defaultOptions.RoleClaimType].ToString())
79+
claims.AddRange(JsonConvert.DeserializeObject<IEnumerable<string>>(xMsClientPrincipal[this.defaultOptions.RoleClaimType]?.ToString() ?? "[]")
8080
.Select(r => new AADClaimsModel { Typ = this.defaultOptions.RoleClaimType, Values = r }));
8181
}
8282
var otherClaims = xMsClientPrincipal.Properties()
@@ -88,8 +88,8 @@ private IEnumerable<AADClaimsModel> BuildFromAuthToken(JObject xMsClientPrincipa
8888
{
8989
Typ = options.NameClaimType,
9090
Values = xMsClientPrincipal.ContainsKey("upn") ?
91-
xMsClientPrincipal["upn"].ToString() : // this appends if an user is using the auth token from the /.auth/me site on the website
92-
xMsClientPrincipal["appid"].ToString() // this appends if an application is try accessing the app.
91+
xMsClientPrincipal["upn"]?.ToString() ?? string.Empty : // this appends if an user is using the auth token from the /.auth/me site on the website
92+
xMsClientPrincipal["appid"]?.ToString() ?? string.Empty // this appends if an application is try accessing the app.
9393
});
9494
return claims;
9595
}

0 commit comments

Comments
 (0)