started moving api layer to shared abstract class
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user