mirror of
https://github.com/byo-software/steam-openid-connect-provider.git
synced 2025-01-09 18:06:22 +00:00
The userName claim is not set through steam. Fallback to id as username for now
This commit is contained in:
parent
f14bf5e6e2
commit
425d7d1d85
1 changed files with 11 additions and 0 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue