diff --git a/Watcher/Controllers/AuthController.cs b/Watcher/Controllers/AuthController.cs index e4f957c..e18d438 100644 --- a/Watcher/Controllers/AuthController.cs +++ b/Watcher/Controllers/AuthController.cs @@ -133,4 +133,46 @@ public class AuthController : Controller return RedirectToAction("Index", "Home"); } + + // Edit-Form anzeigen + [Authorize] + [HttpGet] + public IActionResult UserSettings() + { + var username = User.Identity?.Name; + var user = _context.Users.FirstOrDefault(u => u.PreferredUsername == username); + if (user == null) return NotFound(); + + var model = new EditUserViewModel + { + Username = user.PreferredUsername + }; + return View(model); + } + + // Edit speichern + [Authorize] + [HttpPost] + [ValidateAntiForgeryToken] + public IActionResult UserSettings(EditUserViewModel model) + { + if (!ModelState.IsValid) return View(model); + + var username = User.Identity?.Name; + var user = _context.Users.FirstOrDefault(u => u.PreferredUsername == username); + if (user == null) return NotFound(); + + user.PreferredUsername = model.Username; + + if (!string.IsNullOrWhiteSpace(model.NewPassword)) + { + user.PreferredUsername = BCrypt.Net.BCrypt.HashPassword(model.NewPassword); + } + + _context.SaveChanges(); + + // Eventuell hier das Auth-Cookie erneuern, wenn Username sich ändert + + return RedirectToAction("Index", "Home"); + } } diff --git a/Watcher/Views/Auth/Info.cshtml b/Watcher/Views/Auth/Info.cshtml index fd257a3..81536ea 100644 --- a/Watcher/Views/Auth/Info.cshtml +++ b/Watcher/Views/Auth/Info.cshtml @@ -19,7 +19,10 @@ @(User.Identity?.Name?.Substring(0,1).ToUpper() ?? "?") } -

@(User.FindFirst("name")?.Value ?? "Unbekannter Nutzer")

+

+ @(User.FindFirst("name")?.Value ?? "Unbekannter Nutzer") +

+ @@ -75,12 +78,18 @@
- -
- -
+
+
+ +
+
+ +
+
@if (isAdmin) diff --git a/Watcher/Views/Auth/UserSettings.cshtml b/Watcher/Views/Auth/UserSettings.cshtml new file mode 100644 index 0000000..040351b --- /dev/null +++ b/Watcher/Views/Auth/UserSettings.cshtml @@ -0,0 +1 @@ +

settings

\ No newline at end of file diff --git a/Watcher/Views/Server/overview.cshtml b/Watcher/Views/Server/overview.cshtml index a157f37..7d7d064 100644 --- a/Watcher/Views/Server/overview.cshtml +++ b/Watcher/Views/Server/overview.cshtml @@ -16,7 +16,7 @@
@foreach (var s in Model.Servers) { -
+

(#@s.Id) @s.Name @@ -133,5 +133,4 @@ } }); -} - +} \ No newline at end of file diff --git a/Watcher/Views/Shared/_Layout.cshtml.css b/Watcher/Views/Shared/_Layout.cshtml.css index c187c02..3407be7 100644 --- a/Watcher/Views/Shared/_Layout.cshtml.css +++ b/Watcher/Views/Shared/_Layout.cshtml.css @@ -1,6 +1,11 @@ /* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification for details on configuring this project to bundle and minify static web assets. */ +html, body { + min-height: 100vh; + overflow-y: auto; +} + a.navbar-brand { white-space: normal; text-align: center; diff --git a/Watcher/persistence/watcher.db-shm b/Watcher/persistence/watcher.db-shm deleted file mode 100644 index fe9ac28..0000000 Binary files a/Watcher/persistence/watcher.db-shm and /dev/null differ diff --git a/Watcher/persistence/watcher.db-wal b/Watcher/persistence/watcher.db-wal deleted file mode 100644 index e69de29..0000000 diff --git a/Watcher/wwwroot/css/ServerOverview.css b/Watcher/wwwroot/css/ServerOverview.css index e69de29..8b13789 100644 --- a/Watcher/wwwroot/css/ServerOverview.css +++ b/Watcher/wwwroot/css/ServerOverview.css @@ -0,0 +1 @@ +