mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Merge pull request #225 from LD-Reborn/223-user-profile---image-and-empty-page
Added user image and navbar elements
This commit is contained in:
@@ -95,6 +95,7 @@ public class HomeController : Controller
|
||||
|
||||
[Authorize(Roles = "CanManageUsers")]
|
||||
[HttpGet("UserPhoto")]
|
||||
[ResponseCache(Duration = 3600, Location = ResponseCacheLocation.Any, VaryByQueryKeys = new[] { "uid", "size" })]
|
||||
public async Task<IActionResult> UserPhotoAsync(string uid, int? size)
|
||||
{
|
||||
UserModel? user = await _ldap.GetUserByUidAsync(uid, _ldap.UsersAttributes);
|
||||
|
||||
36
src/Controllers/SettingsController.cs
Normal file
36
src/Controllers/SettingsController.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Berufsschule_HAM.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Novell.Directory.Ldap;
|
||||
using Berufsschule_HAM.Models;
|
||||
using Berufsschule_HAM.Helpers;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using System.Text.Json;
|
||||
using System.Buffers.Text;
|
||||
|
||||
[Authorize]
|
||||
[Route("[controller]")]
|
||||
public class SettingsController : Controller
|
||||
{
|
||||
private readonly LdapService _ldap;
|
||||
private readonly ILogger<UsersController> _logger;
|
||||
|
||||
public SettingsController(LdapService ldap, ILogger<UsersController> logger)
|
||||
{
|
||||
_ldap = ldap;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet("User")]
|
||||
public new IActionResult User(UsersIndexRequestModel requestModel)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet("Admin")]
|
||||
public IActionResult Admin(UsersIndexRequestModel requestModel)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
1
src/Views/Settings/Admin.cshtml
Normal file
1
src/Views/Settings/Admin.cshtml
Normal file
@@ -0,0 +1 @@
|
||||
<h3>Empty view lol</h3>
|
||||
1
src/Views/Settings/User.cshtml
Normal file
1
src/Views/Settings/User.cshtml
Normal file
@@ -0,0 +1 @@
|
||||
<h3>Empty view lol</h3>
|
||||
@@ -1,6 +1,9 @@
|
||||
@using Microsoft.AspNetCore.Mvc.Localization
|
||||
@using System.Security.Claims
|
||||
@inject IViewLocalizer T
|
||||
@{
|
||||
bool IsAuthenticated = User.Identity?.IsAuthenticated ?? false;
|
||||
}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@@ -42,7 +45,7 @@
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
@if (User.Identity?.IsAuthenticated ?? false)
|
||||
@if (IsAuthenticated)
|
||||
{
|
||||
@if (User.HasClaim(ClaimTypes.Role, "CanInventorize"))
|
||||
{
|
||||
@@ -75,17 +78,32 @@
|
||||
</li>
|
||||
}
|
||||
}
|
||||
@if (!IsAuthenticated)
|
||||
{
|
||||
<li class="nav-item">
|
||||
@if (User.Identity.IsAuthenticated)
|
||||
{
|
||||
<a class="nav-link text" asp-area="" asp-controller="Home" asp-action="Logout">@T["Log out"]</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a class="nav-link text" asp-area="" asp-controller="Home" asp-action="Login">@T["Login"]</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
@if (IsAuthenticated && User.Identity is not null)
|
||||
{
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item dropdown">
|
||||
<div class="nav-link dropdown-toggle d-flex align-items-center" href="#" id="userDropdown" role="button"
|
||||
data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<img src="/Home/UserPhoto?uid=@User.Identity.Name&size=256" alt="Profile"
|
||||
class="rounded-circle me-2" width="30" height="30" />
|
||||
<span>@User.Identity.Name</span>
|
||||
</div>
|
||||
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="userDropdown">
|
||||
<li><a class="dropdown-item" asp-controller="Settings" asp-action="User">@T["User settings"]</a></li>
|
||||
<li><a class="dropdown-item" asp-controller="Settings" asp-action="Admin">@T["Admin settings"]</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" asp-controller="Home" asp-action="Logout">@T["Log out"]</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
Reference in New Issue
Block a user