started moving api layer to shared abstract class

This commit is contained in:
2021-10-20 16:22:49 -04:00
parent c91a7cf7e2
commit 5b46e2fb15
10 changed files with 90 additions and 18 deletions

View File

@@ -1,13 +1,29 @@
using System;
using System.Linq;
using System.Security.Claims;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Net.Http.Headers;
using WebAPI.Auth;
using WebAPI.Data;
using WebAPI.Data.Models;
namespace WebAPI.Controllers
{
public class BaseController : ControllerBase
{
[Inject]
protected AppDbContext AppDbContext { get; private set; }
public BaseController(IServiceProvider serviceProvider)
{
AppDbContext = serviceProvider.GetRequiredService<AppDbContext>();
}
protected User DbUser => AppDbContext.Users.FirstOrDefault(user =>
user.ExternalAuthIdentifier == User.FindFirstValue(OIDCClaimTypes.Subject));
}
}