Auth und Usercontroller getrennt + Mail Settings NUR FRONTEND
This commit is contained in:
0
Watcher/Views/User/EditUser.cshtml
Normal file
0
Watcher/Views/User/EditUser.cshtml
Normal file
95
Watcher/Views/User/Info.cshtml
Normal file
95
Watcher/Views/User/Info.cshtml
Normal file
@@ -0,0 +1,95 @@
|
||||
@{
|
||||
ViewData["Title"] = "Account Info";
|
||||
var pictureUrl = User.Claims.FirstOrDefault(c => c.Type == "picture")?.Value ?? "";
|
||||
var preferredUsername = User.Claims.FirstOrDefault(c => c.Type == "preferred_username")?.Value ?? "admin";
|
||||
var isAdmin = preferredUsername == "admin";
|
||||
var preferred_username = ViewBag.name;
|
||||
}
|
||||
|
||||
<div class="container mt-5">
|
||||
<div class="card shadow-lg rounded-3 p-4" style="max-width: 700px; margin: auto;">
|
||||
<div class="text-center mb-4">
|
||||
@if (!string.IsNullOrEmpty(pictureUrl))
|
||||
{
|
||||
<img src="@pictureUrl" alt="Profilbild" class="rounded-circle shadow" style="width: 120px; height: 120px; object-fit: cover;" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="bg-secondary text-white rounded-circle d-inline-flex align-items-center justify-content-center"
|
||||
style="width: 120px; height: 120px; font-size: 48px;">
|
||||
<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("PreferredUsername")?.Value ?? "Unbekannter Nutzer")
|
||||
</h3>
|
||||
|
||||
</div>
|
||||
|
||||
<table class="table table-hover">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><i class="bi bi-person-badge me-1"></i>Username</th>
|
||||
<td>@preferredUsername</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><i class="bi bi-envelope me-1"></i>E-Mail</th>
|
||||
<td>@(ViewBag.Mail ?? "Nicht verfügbar")</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><i class="bi bi-fingerprint me-1"></i>Benutzer-ID</th>
|
||||
<td>@(ViewBag.Id ?? "Nicht verfügbar")</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><i class="bi bi-clock-history me-1"></i>Login-Zeit</th>
|
||||
<td>
|
||||
@(User.FindFirst("iat") != null
|
||||
? DateTimeOffset.FromUnixTimeSeconds(long.Parse(User.FindFirst("iat").Value)).ToLocalTime().ToString()
|
||||
: "Nicht verfügbar")
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><i class="bi bi-hourglass-split me-1"></i>Token läuft ab</th>
|
||||
<td>
|
||||
@(User.FindFirst("exp") != null
|
||||
? DateTimeOffset.FromUnixTimeSeconds(long.Parse(User.FindFirst("exp").Value)).ToLocalTime().ToString()
|
||||
: "Nicht verfügbar")
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><i class="bi bi-shield-lock me-1"></i>Rollen</th>
|
||||
<td>
|
||||
@{
|
||||
var roles = User.FindAll("role").Select(r => r.Value);
|
||||
if (!roles.Any())
|
||||
{
|
||||
<span class="text-muted">Keine Rollen</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ul class="mb-0">
|
||||
@foreach (var role in roles)
|
||||
{
|
||||
<li><i class="bi bi-tag me-1 text-primary"></i>@role</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div>
|
||||
<form method="get" asp-controller="User" 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>
|
||||
</div>
|
163
Watcher/Views/User/UserSettings.cshtml
Normal file
163
Watcher/Views/User/UserSettings.cshtml
Normal file
@@ -0,0 +1,163 @@
|
||||
@{
|
||||
ViewData["Title"] = "Settings";
|
||||
var pictureUrl = User.Claims.FirstOrDefault(c => c.Type == "picture")?.Value ?? "";
|
||||
var preferredUsername = User.Claims.FirstOrDefault(c => c.Type == "preferred_username")?.Value ?? "admin";
|
||||
var isLocalUser = ViewBag.IdentityProvider == "local";
|
||||
var DbEngine = ViewBag.DbProvider;
|
||||
}
|
||||
|
||||
<style>
|
||||
.Settingscontainer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
/* Wichtig: erlaubt Umbruch */
|
||||
gap: 1rem;
|
||||
/* optionaler Abstand */
|
||||
}
|
||||
|
||||
.Settingscontainer>* {
|
||||
flex: 1 1 calc(50% - 0.5rem);
|
||||
/* 2 Elemente pro Zeile, inkl. Gap */
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="Settingscontainer">
|
||||
@if (isLocalUser)
|
||||
{
|
||||
<div class="card shadow mt-5 p-4" style="width: 40%; margin: auto;">
|
||||
<h4><i class="bi bi-pencil-square me-2"></i>Benutzerdaten ändern</h4>
|
||||
<form asp-action="Edit" method="post" asp-controller="User">
|
||||
<div class="mb-3">
|
||||
<label for="Username" class="form-label">Neuer Benutzername</label>
|
||||
<input type="text" class="form-control" id="Username" name="Username" value="@preferredUsername" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="NewPassword" class="form-label">Neues Passwort</label>
|
||||
<input type="password" class="form-control" id="NewPassword" name="NewPassword" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="ConfirmPassword" class="form-label">Passwort bestätigen</label>
|
||||
<input type="password" class="form-control" id="ConfirmPassword" name="ConfirmPassword" />
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-save me-1"></i>Speichern
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="alert alert-info mt-4 text-center" style="width: 40%; margin: auto;">
|
||||
<i class="bi bi-info-circle me-1"></i>Benutzerdaten können nur für lokal angemeldete Nutzer geändert werden.
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
<div class="card shadow mt-5 p-4" style="width: 55%; margin: auto;">
|
||||
<h4><i class="bi bi-pencil-square me-2"></i>Systemeinformationen</h4>
|
||||
|
||||
<br>
|
||||
|
||||
<h5>Watcher Version: v0.1.0</h5>
|
||||
|
||||
<hr class="my-4" />
|
||||
|
||||
<h5>Authentifizierungsmethode: </h5>
|
||||
<p><strong>@(ViewBag.IdentityProvider ?? "nicht gefunden")</strong></p>
|
||||
|
||||
<hr class="my-4" />
|
||||
|
||||
<h5>Datenbank-Engine: </h5>
|
||||
<strong>@(DbEngine ?? "nicht gefunden")</strong>
|
||||
|
||||
<!-- Falls Sqlite verwendet wird können Backups erstellt werden -->
|
||||
@if (DbEngine == "Microsoft.EntityFrameworkCore.Sqlite")
|
||||
{
|
||||
<div class="d-flex gap-2">
|
||||
<form asp-action="CreateSqlDump" method="post" asp-controller="Database">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-save me-1"></i> Backup erstellen
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<form asp-action="ManageSqlDumps" method="post" asp-controller="Database">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-save me-1"></i> Backups verwalten
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
}
|
||||
else if (DbEngine == "Microsoft.EntityFrameworkCore.MySQL")
|
||||
{
|
||||
<p> MySQL Dump aktuell nicht möglich </p>
|
||||
}
|
||||
|
||||
<!-- Status für Erstellung eines Backups -->
|
||||
@if (TempData["DumpMessage"] != null)
|
||||
{
|
||||
<div class="alert alert-success">
|
||||
<i class="bi bi-check-circle me-1"></i>@TempData["DumpMessage"]
|
||||
</div>
|
||||
}
|
||||
@if (TempData["DumpError"] != null)
|
||||
{
|
||||
<div class="alert alert-danger">
|
||||
<i class="bi bi-exclamation-circle me-1"></i>@TempData["DumpError"]
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card shadow mt-5 p-4" style="width: 55%; margin: auto;">
|
||||
<h4><i class="bi bi-pencil-square me-2"></i>Systemeinstellungen ändern</h4>
|
||||
|
||||
<h5>Anzeigeeinstellungen: </h5>
|
||||
|
||||
<hr class="my-4" />
|
||||
|
||||
<h5>Benachrichtigungen: </h5>
|
||||
<p>Registrierte E-Mail Adresse: <strong>@(ViewBag.mail ?? "nicht gefunden")</strong></p>
|
||||
|
||||
<!-- action="/Notification/UpdateSettings" existiert noch nicht-->
|
||||
<form method="post" action="#">
|
||||
<div class="card p-4 shadow-sm" style="max-width: 500px;">
|
||||
<h5 class="card-title mb-3">
|
||||
<i class="bi bi-bell me-2"></i>Benachrichtigungseinstellungen
|
||||
</h5>
|
||||
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input class="form-check-input" type="checkbox" id="notifyOffline" name="NotifyOffline" checked>
|
||||
<label class="form-check-label" for="notifyOffline">Benachrichtigung bei Server-Offline</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input class="form-check-input" type="checkbox" id="notifyUpdates" name="NotifyUpdates">
|
||||
<label class="form-check-label" for="notifyUpdates">Benachrichtigung bei neuen Updates</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input class="form-check-input" type="checkbox" id="notifyUser" name="NotifyUser">
|
||||
<label class="form-check-label" for="notifyUser">Benachrichtigung bei neuen Benutzern</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input class="form-check-input" type="checkbox" id="notifyMaintenance" name="NotifyMaintenance">
|
||||
<label class="form-check-label" for="notifyMaintenance">Wartungsinformationen erhalten</label>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary mt-3">
|
||||
<i class="bi bi-save me-1"></i>Speichern
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<hr class="my-4" />
|
||||
|
||||
<h5>...: </h5>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
Reference in New Issue
Block a user