blob: 37371745cb7db67b19a5b58331cde16b795e4433 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
using System;
using Microsoft.AspNetCore.Mvc;
using Dough.Utilities;
using IdentityModel;
using Microsoft.AspNetCore.Authorization;
namespace Dough.Controllers
{
[ApiController]
[Authorize]
[Route("[controller]")]
public class BaseController : ControllerBase
{
public LoggedInUserModel LoggedInUser => new LoggedInUserModel
{
Id = User.GetClaimValueOrDefault(JwtClaimTypes.Subject)?.ToGuidOrDefault() ?? default,
Username = User.GetClaimValueOrDefault(JwtClaimTypes.PreferredUserName),
};
public class LoggedInUserModel
{
public Guid Id { get; set; }
public string Username { get; set; }
}
}
}
|