27 lines
687 B
C#
27 lines
687 B
C#
|
using Microsoft.AspNetCore.Http;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace HanyadikHetVan.Services
|
|||
|
{
|
|||
|
public class IdentityService
|
|||
|
{
|
|||
|
private readonly IHttpContextAccessor httpContextAccessor;
|
|||
|
|
|||
|
public IdentityService(IHttpContextAccessor httpContextAccessor)
|
|||
|
{
|
|||
|
this.httpContextAccessor = httpContextAccessor;
|
|||
|
}
|
|||
|
|
|||
|
public string GetUserId()
|
|||
|
{
|
|||
|
return
|
|||
|
httpContextAccessor.HttpContext.User.Claims
|
|||
|
.SingleOrDefault(x => x.Type.ToLower() == "sub")
|
|||
|
?.Value ?? throw new Exception();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|