aboutsummaryrefslogtreecommitdiffstats
path: root/src/Controllers/AppControllerBase.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Controllers/AppControllerBase.cs')
-rw-r--r--src/Controllers/AppControllerBase.cs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Controllers/AppControllerBase.cs b/src/Controllers/AppControllerBase.cs
new file mode 100644
index 0000000..36b52d7
--- /dev/null
+++ b/src/Controllers/AppControllerBase.cs
@@ -0,0 +1,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
+ };
+ }
+}