aboutsummaryrefslogtreecommitdiffstats
path: root/src/Controllers/AppControllerBase.cs
blob: 36b52d7c20c34545f6e01b18a07d5056dedb7bc3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System.Linq;
using System.Security.Claims;
using IOL.WebApi.Template.Data.General;
using IOL.Helpers;
using Microsoft.AspNetCore.Mvc;

namespace IOL.WebApi.Template.Controllers
{
	[ApiController]
	[Route("api/[controller]")]
	public class AppControllerBase : ControllerBase
	{
		public string CurrentHost => Request.GetRequestHost();

		public AppControllerBase() { }

		public LoggedInUser LoggedInUser => new() {
				Username = User.Identity?.Name,
				Id = User.Claims.SingleOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value.ToGuid() ?? default
		};
	}
}