Add APIAuth Role
This commit is contained in:
@@ -6,7 +6,7 @@ namespace CarCareTracker.Controllers
|
|||||||
{
|
{
|
||||||
public IActionResult Unauthorized()
|
public IActionResult Unauthorized()
|
||||||
{
|
{
|
||||||
if (!User.IsInRole("CookieAuth"))
|
if (User.IsInRole("APIAuth"))
|
||||||
{
|
{
|
||||||
Response.StatusCode = 403;
|
Response.StatusCode = 403;
|
||||||
return new EmptyResult();
|
return new EmptyResult();
|
||||||
|
|||||||
@@ -75,7 +75,9 @@ namespace CarCareTracker.Middleware
|
|||||||
var userIdentity = new List<Claim>
|
var userIdentity = new List<Claim>
|
||||||
{
|
{
|
||||||
new(ClaimTypes.Name, splitString[0]),
|
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)
|
if (userData.IsAdmin)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
<li class="nav-item" role="presentation">
|
<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>
|
<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>
|
</li>
|
||||||
@if (User.IsInRole("CookieAuth"))
|
@if (User.IsInRole("CookieAuth") || User.IsInRole("APIAuth"))
|
||||||
{
|
{
|
||||||
@if (User.IsInRole(nameof(UserData.IsAdmin)))
|
@if (User.IsInRole(nameof(UserData.IsAdmin)))
|
||||||
{
|
{
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
<li class="nav-item ms-auto" role="presentation">
|
<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>
|
<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>
|
</li>
|
||||||
@if (User.IsInRole("CookieAuth"))
|
@if (User.IsInRole("CookieAuth") || User.IsInRole("APIAuth"))
|
||||||
{
|
{
|
||||||
<li class="nav-item dropdown" role="presentation">
|
<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>
|
<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>
|
||||||
|
|||||||
Reference in New Issue
Block a user