Added new API for getting Member (aka Users but for use in FE). User is just used for login/registering.
This commit is contained in:
parent
a920be092d
commit
13ed323949
14 changed files with 172 additions and 65 deletions
|
|
@ -1,6 +1,8 @@
|
|||
using API.Data;
|
||||
using API.Helpers;
|
||||
using API.Interfaces;
|
||||
using API.Services;
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
|
@ -11,6 +13,8 @@ namespace API.Extensions
|
|||
{
|
||||
public static IServiceCollection AddApplicationServices(this IServiceCollection services, IConfiguration config)
|
||||
{
|
||||
services.AddAutoMapper(typeof(AutoMapperProfiles).Assembly);
|
||||
services.AddScoped<IUserRepository, UserRepository>();
|
||||
services.AddScoped<ITokenService, TokenService>();
|
||||
services.AddDbContext<DataContext>(options =>
|
||||
{
|
||||
|
|
|
|||
12
API/Extensions/ClaimsPrincipalExtensions.cs
Normal file
12
API/Extensions/ClaimsPrincipalExtensions.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using System.Security.Claims;
|
||||
|
||||
namespace API.Extensions
|
||||
{
|
||||
public static class ClaimsPrincipalExtensions
|
||||
{
|
||||
public static string GetUsername(this ClaimsPrincipal user)
|
||||
{
|
||||
return user.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue