From fe3ab8e4497bf1ca1445063669a49e6e110486df Mon Sep 17 00:00:00 2001 From: LD-Reborn Date: Sat, 1 Nov 2025 22:22:41 +0100 Subject: [PATCH] Added user image and navbar elements --- src/Controllers/HomeController.cs | 1 + src/Controllers/SettingsController.cs | 36 +++++++++++++++++++++++++ src/Views/Settings/Admin.cshtml | 1 + src/Views/Settings/User.cshtml | 1 + src/Views/Shared/_Layout.cshtml | 38 ++++++++++++++++++++------- 5 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 src/Controllers/SettingsController.cs create mode 100644 src/Views/Settings/Admin.cshtml create mode 100644 src/Views/Settings/User.cshtml diff --git a/src/Controllers/HomeController.cs b/src/Controllers/HomeController.cs index 88106b0..6255c94 100644 --- a/src/Controllers/HomeController.cs +++ b/src/Controllers/HomeController.cs @@ -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 UserPhotoAsync(string uid, int? size) { UserModel? user = await _ldap.GetUserByUidAsync(uid, _ldap.UsersAttributes); diff --git a/src/Controllers/SettingsController.cs b/src/Controllers/SettingsController.cs new file mode 100644 index 0000000..41a76af --- /dev/null +++ b/src/Controllers/SettingsController.cs @@ -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 _logger; + + public SettingsController(LdapService ldap, ILogger logger) + { + _ldap = ldap; + _logger = logger; + } + + [HttpGet("User")] + public new IActionResult User(UsersIndexRequestModel requestModel) + { + return View(); + } + + [HttpGet("Admin")] + public IActionResult Admin(UsersIndexRequestModel requestModel) + { + return View(); + } +} \ No newline at end of file diff --git a/src/Views/Settings/Admin.cshtml b/src/Views/Settings/Admin.cshtml new file mode 100644 index 0000000..e9c7309 --- /dev/null +++ b/src/Views/Settings/Admin.cshtml @@ -0,0 +1 @@ +

Empty view lol

\ No newline at end of file diff --git a/src/Views/Settings/User.cshtml b/src/Views/Settings/User.cshtml new file mode 100644 index 0000000..e9c7309 --- /dev/null +++ b/src/Views/Settings/User.cshtml @@ -0,0 +1 @@ +

Empty view lol

\ No newline at end of file diff --git a/src/Views/Shared/_Layout.cshtml b/src/Views/Shared/_Layout.cshtml index fd97d68..84a6135 100644 --- a/src/Views/Shared/_Layout.cshtml +++ b/src/Views/Shared/_Layout.cshtml @@ -1,6 +1,9 @@ @using Microsoft.AspNetCore.Mvc.Localization @using System.Security.Claims @inject IViewLocalizer T +@{ + bool IsAuthenticated = User.Identity?.IsAuthenticated ?? false; +} @@ -42,7 +45,7 @@