_LoginPartial.cshtml
1,996 bytes
| 1 | @using System.Security.Claims |
|---|---|
| 2 | |
| 3 | @if (User.Identity?.IsAuthenticated == true) |
| 4 | { |
| 5 | var firstName = User.FindFirstValue(ClaimTypes.GivenName); |
| 6 | var lastName = User.FindFirstValue(ClaimTypes.Surname); |
| 7 | var initials = (firstName?.Length > 0 ? firstName[0].ToString() : "") + |
| 8 | (lastName?.Length > 0 ? lastName[0].ToString() : ""); |
| 9 | |
| 10 | <div class="dropdown"> |
| 11 | <button class="sa-nav-avatar-btn dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false" |
| 12 | data-bs-auto-close="true" style="border: none;"> |
| 13 | <span class="sa-avatar sa-avatar-sm sa-avatar-2" style="border:none;">@initials</span> |
| 14 | <span class="sa-hide-mobile">@User.Identity?.Name</span> |
| 15 | </button> |
| 16 | <ul class="dropdown-menu dropdown-menu-end"> |
| 17 | <li> |
| 18 | <a class="dropdown-item" asp-controller="Account" asp-action="Manage" asp-area=""> |
| 19 | <i class="bi bi-person me-2"></i>@Localizer["Profile"] |
| 20 | </a> |
| 21 | </li> |
| 22 | <li><hr class="dropdown-divider" /></li> |
| 23 | <li> |
| 24 | <form class="form-inline" asp-controller="Account" asp-action="Logout" asp-area="" |
| 25 | asp-route-returnUrl="@Url.Action("Index", "Home", new { area = "" })" method="post"> |
| 26 | @Html.AntiForgeryToken() |
| 27 | <button type="submit" class="dropdown-item text-danger"> |
| 28 | <i class="bi bi-box-arrow-right me-2"></i>@Localizer["Logout"] |
| 29 | </button> |
| 30 | </form> |
| 31 | </li> |
| 32 | </ul> |
| 33 | </div> |
| 34 | } |
| 35 | else |
| 36 | { |
| 37 | <div class="sa-navbar-auth-btns"> |
| 38 | <a class="sa-btn sa-btn-ghost sa-btn-sm" asp-controller="Account" asp-action="Login" asp-area=""> |
| 39 | @Localizer["Log in"] |
| 40 | </a> |
| 41 | <a class="sa-btn sa-btn-primary sa-btn-sm sa-btn-pill" asp-controller="Account" asp-action="Register" asp-area=""> |
| 42 | @Localizer["Sign up"] |
| 43 | </a> |
| 44 | </div> |
| 45 | } |
| 46 | |