diff options
Diffstat (limited to 'src/Controllers/MainControllerBase.cs')
| -rw-r--r-- | src/Controllers/MainControllerBase.cs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/Controllers/MainControllerBase.cs b/src/Controllers/MainControllerBase.cs new file mode 100644 index 0000000..4f8f47f --- /dev/null +++ b/src/Controllers/MainControllerBase.cs @@ -0,0 +1,26 @@ +using System; +using System.Linq; +using System.Security.Claims; +using IOL.Helpers; +using Microsoft.AspNetCore.Mvc; + +namespace VSH.Controllers; + +[ApiController] +[Route("api/[controller]")] +public class MainControllerBase : ControllerBase +{ + public string CurrentHost => Request.GetRequestHost(); + + + protected LoggedInUserModel LoggedInUser => new() { + Username = User.Identity?.Name, + Id = User.Claims.SingleOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value.ToGuid() ?? default + }; + + protected class LoggedInUserModel + { + public Guid Id { get; set; } + public string Username { get; set; } + } +}
\ No newline at end of file |
