Torma Kristóf
634488c2d8
All checks were successful
continuous-integration/drone/push Build is passing
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();
|
|
}
|
|
}
|
|
}
|