1
0
mirror of https://github.com/chylex/Minecraft-Phantom-Panel.git synced 2024-11-22 08:42:44 +01:00
Minecraft-Phantom-Panel/Server/Phantom.Server.Services/Users/IdentityLookup.cs

17 lines
468 B
C#

using System.Security.Claims;
using Microsoft.AspNetCore.Identity;
namespace Phantom.Server.Services.Users;
public sealed class IdentityLookup {
private readonly UserManager<IdentityUser> userManager;
public IdentityLookup(UserManager<IdentityUser> userManager) {
this.userManager = userManager;
}
public string? GetAuthenticatedUserId(ClaimsPrincipal user) {
return user.Identity is { IsAuthenticated: true } ? userManager.GetUserId(user) : null;
}
}