Settings Page erstellt
This commit is contained in:
@@ -133,4 +133,46 @@ public class AuthController : Controller
|
|||||||
|
|
||||||
return RedirectToAction("Index", "Home");
|
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>
|
<span>@(User.Identity?.Name?.Substring(0,1).ToUpper() ?? "?")</span>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
|
|
||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
@@ -75,12 +78,18 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<div>
|
||||||
<form method="post" asp-controller="Auth" asp-action="Logout" class="text-center mt-4">
|
<form method="get" asp-controller="Auth" asp-action="UserSettings" class="text-center mt-4">
|
||||||
<button type="submit" class="btn btn-danger">
|
<button type="submit" class="btn btn-info">
|
||||||
<i class="bi bi-box-arrow-right me-1"></i>Abmelden
|
<i class="bi bi-gear-wide-connected me-1"></i>Einstellungen
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</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>
|
</div>
|
||||||
|
|
||||||
@if (isAdmin)
|
@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">
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||||
@foreach (var s in Model.Servers)
|
@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">
|
<div class="flex justify-between items-center">
|
||||||
<h2 class="text-lg font-semibold text-gray-800">
|
<h2 class="text-lg font-semibold text-gray-800">
|
||||||
<i class="bi bi-cpu me-1 text-gray-600"></i>(#@s.Id) @s.Name
|
<i class="bi bi-cpu me-1 text-gray-600"></i>(#@s.Id) @s.Name
|
||||||
@@ -134,4 +134,3 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,11 @@
|
|||||||
/* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
/* 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. */
|
for details on configuring this project to bundle and minify static web assets. */
|
||||||
|
|
||||||
|
html, body {
|
||||||
|
min-height: 100vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
a.navbar-brand {
|
a.navbar-brand {
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
|
Reference in New Issue
Block a user