feat: resolve player display names from Steam persona (Steam Web API)
Build & Deploy / build (push) Successful in 41s
Build & Deploy / build (push) Successful in 41s
Accounts were created as 'Unknown' and the client never sends a name, so the admin panel / friends / squad showed no names. Add SteamWebApiService (GetPlayerSummaries), wired into LoginWithSteam to backfill the DisplayName from the Steam persona when it's still 'Unknown'. Admin gets a LAN-only /admin/backfill-names action (+ button) to backfill existing accounts in one shot. Key read from config SteamWebApiKey (Vault -> env), inert when unset. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,7 @@ public class ClientController : Controller
|
||||
private readonly DbEntityService _entityService;
|
||||
private readonly UserDataService _userDataService;
|
||||
private readonly TitleDataService _titleDataService;
|
||||
private readonly Prospect.Server.Api.Services.Steam.SteamWebApiService _steamWebApi;
|
||||
|
||||
public ClientController(ILogger<ClientController> logger,
|
||||
IOptions<PlayFabSettings> settings,
|
||||
@@ -39,7 +40,8 @@ public class ClientController : Controller
|
||||
DbUserService userService,
|
||||
DbEntityService entityService,
|
||||
UserDataService userDataService,
|
||||
TitleDataService titleDataService)
|
||||
TitleDataService titleDataService,
|
||||
Prospect.Server.Api.Services.Steam.SteamWebApiService steamWebApi)
|
||||
{
|
||||
_settings = settings.Value;
|
||||
_logger = logger;
|
||||
@@ -48,6 +50,7 @@ public class ClientController : Controller
|
||||
_entityService = entityService;
|
||||
_userDataService = userDataService;
|
||||
_titleDataService = titleDataService;
|
||||
_steamWebApi = steamWebApi;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
@@ -63,6 +66,19 @@ public class ClientController : Controller
|
||||
var userSteamId = ticket.SteamId.ToString();
|
||||
|
||||
var user = await _userService.FindOrCreateAsync(PlayFabUserAuthType.Steam, userSteamId);
|
||||
|
||||
// Backfill the display name from the Steam persona when we don't have a real
|
||||
// one yet (accounts are created as "Unknown"; the client never sends a name).
|
||||
if (string.IsNullOrEmpty(user.DisplayName) || user.DisplayName == "Unknown")
|
||||
{
|
||||
var persona = await _steamWebApi.GetPersonaNameAsync(userSteamId);
|
||||
if (!string.IsNullOrWhiteSpace(persona))
|
||||
{
|
||||
await _userService.UpdateDisplayNameAsync(user.Id, persona);
|
||||
user.DisplayName = persona;
|
||||
}
|
||||
}
|
||||
|
||||
var entity = await _entityService.FindOrCreateAsync(user.Id);
|
||||
|
||||
var userTicket = _authTokenService.GenerateUser(entity);
|
||||
|
||||
Reference in New Issue
Block a user