105 lines
3.9 KiB
Plaintext
105 lines
3.9 KiB
Plaintext
@{
|
|
ViewData["Title"] = "Account Info";
|
|
var pictureUrl = User.Claims.FirstOrDefault(c => c.Type == "picture")?.Value ?? "123";
|
|
}
|
|
|
|
<h2>Account Info</h2>
|
|
|
|
<div class="card" style="max-width: 600px; margin: auto; padding: 1rem; box-shadow: 0 0 10px #ccc; text-align:center;">
|
|
@if (!string.IsNullOrEmpty(pictureUrl))
|
|
{
|
|
<img src="@pictureUrl" alt="Profilbild" style="width:120px; height:120px; border-radius:50%; object-fit:cover; margin-bottom:1rem;" />
|
|
}
|
|
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>
|
|
}
|
|
|
|
<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>
|
|
}
|