diff --git a/Controllers/ErrorController.cs b/Controllers/ErrorController.cs index bd753f2..aaeb7c6 100644 --- a/Controllers/ErrorController.cs +++ b/Controllers/ErrorController.cs @@ -6,7 +6,7 @@ namespace CarCareTracker.Controllers { public IActionResult Unauthorized() { - if (!User.IsInRole("CookieAuth")) + if (User.IsInRole("APIAuth")) { Response.StatusCode = 403; return new EmptyResult(); diff --git a/Middleware/Authen.cs b/Middleware/Authen.cs index aca0d0b..32e86ab 100644 --- a/Middleware/Authen.cs +++ b/Middleware/Authen.cs @@ -75,7 +75,9 @@ namespace CarCareTracker.Middleware var userIdentity = new List { new(ClaimTypes.Name, splitString[0]), - new(ClaimTypes.NameIdentifier, userData.Id.ToString()) + new(ClaimTypes.NameIdentifier, userData.Id.ToString()), + new(ClaimTypes.Email, userData.EmailAddress), + new(ClaimTypes.Role, "APIAuth") }; if (userData.IsAdmin) { diff --git a/Views/Home/Index.cshtml b/Views/Home/Index.cshtml index 16c843d..2738f67 100644 --- a/Views/Home/Index.cshtml +++ b/Views/Home/Index.cshtml @@ -33,7 +33,7 @@ - @if (User.IsInRole("CookieAuth")) + @if (User.IsInRole("CookieAuth") || User.IsInRole("APIAuth")) { @if (User.IsInRole(nameof(UserData.IsAdmin))) { @@ -84,7 +84,7 @@ - @if (User.IsInRole("CookieAuth")) + @if (User.IsInRole("CookieAuth") || User.IsInRole("APIAuth")) {