From 7d2667ebb2ec78a64a92d134368aab5c67f65ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enes=20Sad=C4=B1k=20=C3=96zbek?= Date: Tue, 13 Oct 2020 01:13:03 +0300 Subject: [PATCH] Fix not being able to login when some steam info is missing --- src/Profile/SteamProfileService.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Profile/SteamProfileService.cs b/src/Profile/SteamProfileService.cs index f5461ed..795f8b9 100644 --- a/src/Profile/SteamProfileService.cs +++ b/src/Profile/SteamProfileService.cs @@ -61,15 +61,23 @@ namespace SteamOpenIdConnectProvider.Profile if (player != null) { - claims.Add(new Claim("picture", player.AvatarFull)); - claims.Add(new Claim("nickname", player.PersonaName)); - claims.Add(new Claim("given_name", player.RealName)); - claims.Add(new Claim("website", player.ProfileUrl)); + AddClaim(claims, "picture", player.AvatarFull); + AddClaim(claims, "nickname", player.PersonaName); + AddClaim(claims, "given_name", player.RealName); + AddClaim(claims, "website", player.ProfileUrl); } context.IssuedClaims = claims; } + private void AddClaim(List claims, string type, string value) + { + if (!string.IsNullOrEmpty(value)) + { + claims.Add(new Claim(type, value)); + } + } + public async Task IsActiveAsync(IsActiveContext context) { var sub = context.Subject.GetSubjectId();