Routes fixed, new ui
This commit is contained in:
@@ -1,104 +1,115 @@
|
||||
@{
|
||||
ViewData["Title"] = "Account Info";
|
||||
var pictureUrl = User.Claims.FirstOrDefault(c => c.Type == "picture")?.Value ?? "123";
|
||||
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";
|
||||
}
|
||||
|
||||
<h2>Account Info</h2>
|
||||
<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("name")?.Value ?? "Unbekannter Nutzer")</h3>
|
||||
</div>
|
||||
|
||||
<div class="card" style="max-width: 600px; margin: auto; padding: 1rem; box-shadow: 0 0 10px #ccc; text-align:center;">
|
||||
@if (!string.IsNullOrEmpty(pictureUrl))
|
||||
<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>@(User.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress")?.Value ?? "Nicht verfügbar")</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><i class="bi bi-fingerprint me-1"></i>Benutzer-ID</th>
|
||||
<td>@(User.FindFirst("sub")?.Value ?? "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>
|
||||
|
||||
<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>
|
||||
|
||||
@if (isAdmin)
|
||||
{
|
||||
<img src="@pictureUrl" alt="Profilbild" style="width:120px; height:120px; border-radius:50%; object-fit:cover; margin-bottom:1rem;" />
|
||||
<div class="card shadow mt-5 p-4" style="max-width: 700px; margin: auto;">
|
||||
<h4><i class="bi bi-pencil-square me-2"></i>Benutzerdaten ändern</h4>
|
||||
<form asp-action="Edit" method="post" asp-controller="Auth">
|
||||
<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 style="width:120px; height:120px; border-radius:50%; background:#ccc; display:inline-block; line-height:120px; font-size:48px; color:#fff; margin-bottom:1rem;">
|
||||
<span>@(User.Identity?.Name?.Substring(0,1).ToUpper() ?? "?")</span>
|
||||
<div class="alert alert-info mt-4 text-center" style="max-width: 700px; margin: auto;">
|
||||
<i class="bi bi-info-circle me-1"></i>Benutzerdaten können nur für lokal angemeldete Nutzer geändert werden.
|
||||
</div>
|
||||
}
|
||||
|
||||
<h3>@(User.FindFirst("name")?.Value ?? "Unbekannter Nutzer")</h3>
|
||||
|
||||
<table class="table" style="margin-top: 1rem;">
|
||||
<tbody>
|
||||
<tr></tr>
|
||||
<th>Username</th>
|
||||
<td>@(@User.Claims.FirstOrDefault(c => c.Type == "preferred_username")?.Value ?? "Nicht verfügbar")</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>E-Mail</th>
|
||||
<td>@(@User.Claims.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress")?.Value ?? "Nicht verfügbar")</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Benutzer-ID</th>
|
||||
<td>@(User.FindFirst("sub")?.Value ?? "Nicht verfügbar")</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>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>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>Rollen</th>
|
||||
<td>
|
||||
@{
|
||||
var roles = User.FindAll("role").Select(r => r.Value);
|
||||
if (!roles.Any())
|
||||
{
|
||||
<text>Keine Rollen</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ul>
|
||||
@foreach (var role in roles)
|
||||
{
|
||||
<li>@role</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<form method="post" asp-controller="Auth" asp-action="Logout">
|
||||
<button type="submit" class="btn btn-danger">Abmelden</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@{
|
||||
|
||||
}
|
||||
@if (User.Identity.Name == "admin")
|
||||
{
|
||||
<h3>Benutzerdaten ändern</h3>
|
||||
<form asp-action="Edit" method="post" asp-controller="Auth">
|
||||
<div class="mb-3">
|
||||
<label for="Username" class="form-label">Username</label>
|
||||
<input type="text" class="form-control" id="Username" name="Username" value="@User.Identity?.Name" />
|
||||
</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">Speichern</button>
|
||||
</form>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>Benutzerdaten können nur für lokal angemeldete Nutzer geändert werden.</p>
|
||||
}
|
||||
|
Reference in New Issue
Block a user