diff --git a/src/Controllers/ExternalLoginController.cs b/src/Controllers/ExternalLoginController.cs index 86e1435..b97747f 100644 --- a/src/Controllers/ExternalLoginController.cs +++ b/src/Controllers/ExternalLoginController.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; @@ -63,6 +64,16 @@ namespace SteamOpenIdConnectProvider.Controllers var userName = info.Principal.FindFirstValue(ClaimTypes.Name); var userId = info.Principal.FindFirstValue(ClaimTypes.NameIdentifier); + if (string.IsNullOrEmpty(userId)) + { + throw new ArgumentNullException(nameof(userId), $"No claim found for {ClaimTypes.NameIdentifier}"); + } + + if (string.IsNullOrEmpty(userName)) + { + userName = userId.Split('/').Last(); + } + var user = new IdentityUser { UserName = userName, Id = userId }; _userManager.UserValidators.Clear();