Skip to content

Commit 95bf974

Browse files
Loggedin user name and role added. Permissions link added
1 parent 4932c09 commit 95bf974

File tree

1 file changed

+50
-25
lines changed

1 file changed

+50
-25
lines changed

ApiIntegrationMvc/Views/Shared/_Layout.cshtml

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
2222
<link rel="stylesheet" href="~/ApiIntegrationMvc.styles.css" asp-append-version="true" />
23-
23+
2424
@RenderSection("Styles", required: false)
2525
</head>
2626
<body>
@@ -59,40 +59,65 @@
5959
</button>
6060

6161
</li>
62-
<li>
63-
64-
</li>
62+
6563

6664
<li class="nav-item">
6765
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">
6866
<i class="bi bi-house-door me-1"></i> Home
6967
</a>
7068
</li>
71-
<li class="nav-item">
72-
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">
73-
<i class="bi bi-shield-lock me-1"></i> Privacy
74-
</a>
75-
</li>
69+
70+
71+
@if (User.IsInRole("Admin"))
72+
{
73+
<li class="nav-item d-none d-sm-block">
74+
<a class="nav-link text-dark" href="#" data-bs-toggle="modal" data-bs-target="#permModal">
75+
<i class="bi bi-shield-lock me-1"></i> Permissions
76+
</a>
77+
</li>
78+
}
79+
80+
7681
</ul>
7782
</div>
78-
83+
7984
<!-- RIGHT: Logout (ALWAYS visible, never collapses) -->
8085
<div class="d-flex ms-auto align-items-center">
81-
@if (User?.Identity?.IsAuthenticated == true)
82-
{
83-
<form asp-area="Account" asp-controller="Login" asp-action="Logout" method="post" class="d-inline">
84-
@Html.AntiForgeryToken()
85-
<button type="submit" class="btn btn-link nav-link">
86-
<i class="bi bi-box-arrow-right me-1"></i> Logout
87-
</button>
88-
</form>
89-
}
90-
else
91-
{
92-
<a class="nav-link" asp-area="Account" asp-controller="Login" asp-action="Index">Login</a>
93-
}
94-
</div>
86+
87+
<ul class="navbar-nav ms-auto align-items-center">
88+
89+
<li class="nav-item d-none d-sm-block">
90+
<div class="d-flex align-items-center text-dark">
91+
<i class="bi bi-person-circle me-1"></i>
92+
<span class="fw-bold">@User.Identity.Name</span>
93+
<small class="text-muted ms-1">
94+
(@User.FindFirst(System.Security.Claims.ClaimTypes.Role)?.Value)
95+
</small>
96+
</div>
97+
</li>
9598

99+
@* Logout / Profile stays as it is *@
100+
@if (User?.Identity?.IsAuthenticated == true)
101+
{
102+
<li>
103+
<form asp-area="Account" asp-controller="Login" asp-action="Logout"
104+
method="post" class="d-inline">
105+
@Html.AntiForgeryToken()
106+
<button type="submit" class="btn btn-link nav-link text-dark">
107+
<i class="bi bi-box-arrow-right me-1"></i> Logout
108+
</button>
109+
</form>
110+
</li>
111+
}
112+
else
113+
{
114+
<li class="nav-item">
115+
<a class="nav-link"
116+
asp-area="Account" asp-controller="Login" asp-action="Index">Login</a>
117+
</li>
118+
}
119+
</ul>
120+
</div>
96121
</div>
97122
</nav>
98123

@@ -172,6 +197,6 @@
172197
});
173198
</script>
174199
}
175-
200+
@await Html.PartialAsync("_PermissionSwitchModal")
176201
</body>
177202
</html>

0 commit comments

Comments
 (0)