29 lines
861 B
C#
29 lines
861 B
C#
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));
|
|
}
|
|
} |