Settings Page erstellt
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,10 @@
|
||||
<span>@(User.Identity?.Name?.Substring(0,1).ToUpper() ?? "?")</span>
|
||||
</div>
|
||||
}
|
||||
<h3 class="mt-3"><i class="bi bi-person-circle me-1"></i>@(User.FindFirst("name")?.Value ?? "Unbekannter Nutzer")</h3>
|
||||
<h3 class="mt-3">
|
||||
<i class="bi bi-person-circle me-1"></i>@(User.FindFirst("name")?.Value ?? "Unbekannter Nutzer")
|
||||
</h3>
|
||||
|
||||
</div>
|
||||
|
||||
<table class="table table-hover">
|
||||
@@ -75,12 +78,18 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<form method="post" asp-controller="Auth" asp-action="Logout" class="text-center mt-4">
|
||||
<button type="submit" class="btn btn-danger">
|
||||
<i class="bi bi-box-arrow-right me-1"></i>Abmelden
|
||||
</button>
|
||||
</form>
|
||||
<div>
|
||||
<form method="get" asp-controller="Auth" asp-action="UserSettings" class="text-center mt-4">
|
||||
<button type="submit" class="btn btn-info">
|
||||
<i class="bi bi-gear-wide-connected me-1"></i>Einstellungen
|
||||
</button>
|
||||
</form>
|
||||
<form method="post" asp-controller="Auth" asp-action="Logout" class="text-center mt-4">
|
||||
<button type="submit" class="btn btn-danger">
|
||||
<i class="bi bi-box-arrow-right me-1"></i>Abmelden
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (isAdmin)
|
||||
|
1
Watcher/Views/Auth/UserSettings.cshtml
Normal file
1
Watcher/Views/Auth/UserSettings.cshtml
Normal file
@@ -0,0 +1 @@
|
||||
<h1>settings</h1>
|
@@ -16,7 +16,7 @@
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
@foreach (var s in Model.Servers)
|
||||
{
|
||||
<div class="bg-white rounded-xl shadow p-5 border border-gray-200 flex flex-col gap-4">
|
||||
<div class="bg-blue rounded-xl shadow p-5 border border-gray-200 flex flex-col gap-4">
|
||||
<div class="flex justify-between items-center">
|
||||
<h2 class="text-lg font-semibold text-gray-800">
|
||||
<i class="bi bi-cpu me-1 text-gray-600"></i>(#@s.Id) @s.Name
|
||||
@@ -133,5 +133,4 @@
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
||||
}
|
@@ -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;
|
||||
|
Binary file not shown.
@@ -0,0 +1 @@
|
||||
|
||||
|
Reference in New Issue
Block a user