Add APIAuth Role

This commit is contained in:
DESKTOP-T0O5CDB\DESK-555BD 2025-02-03 13:34:50 -07:00
parent cd0a35537b
commit c0f73080d2
3 changed files with 6 additions and 4 deletions

View File

@ -6,7 +6,7 @@ namespace CarCareTracker.Controllers
{
public IActionResult Unauthorized()
{
if (!User.IsInRole("CookieAuth"))
if (User.IsInRole("APIAuth"))
{
Response.StatusCode = 403;
return new EmptyResult();

View File

@ -75,7 +75,9 @@ namespace CarCareTracker.Middleware
var userIdentity = new List<Claim>
{
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)
{

View File

@ -33,7 +33,7 @@
<li class="nav-item" role="presentation">
<button class="nav-link @(Model == "settings" ? "active" : "")" id="settings-tab" data-bs-toggle="tab" data-bs-target="#settings-tab-pane" type="button" role="tab"><span class="ms-2 display-3"><i class="bi bi-gear me-2"></i>@translator.Translate(userLanguage,"Settings")</span></button>
</li>
@if (User.IsInRole("CookieAuth"))
@if (User.IsInRole("CookieAuth") || User.IsInRole("APIAuth"))
{
@if (User.IsInRole(nameof(UserData.IsAdmin)))
{
@ -84,7 +84,7 @@
<li class="nav-item ms-auto" role="presentation">
<button class="nav-link resizable-nav-link @(Model == "settings" ? "active" : "")" id="settings-tab" data-bs-toggle="tab" data-bs-target="#settings-tab-pane" type="button" role="tab"><i class="bi bi-gear"></i><span class="ms-2 d-sm-none d-md-inline">@translator.Translate(userLanguage, "Settings")</span></button>
</li>
@if (User.IsInRole("CookieAuth"))
@if (User.IsInRole("CookieAuth") || User.IsInRole("APIAuth"))
{
<li class="nav-item dropdown" role="presentation">
<a class="nav-link resizable-nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false"><i class="bi bi-person"></i><span class="ms-2 d-sm-none d-md-inline">@User.Identity.Name</span></a>