67 lines
2.5 KiB
Plaintext
67 lines
2.5 KiB
Plaintext
@page "/Admin/User/{id:int}/Edit"
|
|
@using Authinator.Backend.Utils
|
|
@using Authinator.Backend.Database
|
|
@using Authinator.Backend.Database.Tables
|
|
@using System.Web
|
|
@using Microsoft.EntityFrameworkCore
|
|
@model AdminEditUserModel
|
|
@{
|
|
ViewData["Title"] = "Edit User - Admin";
|
|
|
|
var user = Model.ModelUser;
|
|
var db = new DatabaseContext();
|
|
|
|
var statusIcon = user.IsSignupComplete ? "bi-check-circle-fill" : "bi-clock-fill";
|
|
var statusText = user.IsSignupComplete ? "User is active" : "Awaiting activation";
|
|
}
|
|
|
|
<form method="POST" class="border rounded px-3 py-3">
|
|
<div class="mb-3 fs-4">
|
|
Editing User: <span class="bg-body-secondary rounded ms-1 px-2 py-1 fw-light">@user.Reference</span>
|
|
<span class="px-2 py-1 rounded fs-4 bg-body-tertiary">
|
|
<span class="fs-6 align-middle">
|
|
<i class="bi @statusIcon"></i> @statusText
|
|
</span>
|
|
</span>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="reference" class="form-label">Admin reference</label>
|
|
<input class="form-control" type="text" id="reference" name="reference" value="@user.Reference" required/>
|
|
</div>
|
|
@if (user.IsSignupComplete) {
|
|
<div class="mb-3">
|
|
<label for="username" class="form-label">Username</label>
|
|
<input class="form-control" type="text" id="username" name="username" placeholder="theirusername" value="@user.Username" required/>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="email" class="form-label">E-Mail</label>
|
|
<input class="form-control" type="email" id="email" name="email" placeholder="their@email.tld" value="@user.Email" required/>
|
|
</div>
|
|
}
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Groups</label>
|
|
@foreach (var group in db.Groups) {
|
|
<div class="form-check">
|
|
@if (user.Groups.Any(p => p == group)) {
|
|
if (group.Name == ConfigCache.AdminGroup && user == HttpContext.GetRemoteUser(db)) {
|
|
<input class="form-check-input" type="checkbox" id="check-group-@group.Id" name="group" value="@group.Id" checked disabled>
|
|
<input type="hidden" id="check-group-@group.Id" name="group" value="@group.Id"> // needed because "disabled" checkboxes aren't sent to the backend, even when checked
|
|
}
|
|
else {
|
|
<input class="form-check-input" type="checkbox" id="check-group-@group.Id" name="group" value="@group.Id" checked>
|
|
}
|
|
}
|
|
else {
|
|
<input class="form-check-input" type="checkbox" id="check-group-@group.Id" name="group" value="@group.Id">
|
|
}
|
|
<label class="form-check-label" for="check-group-@group.Id">
|
|
@group.Name
|
|
</label>
|
|
</div>
|
|
}
|
|
</div>
|
|
|
|
<button class="btn btn-primary" type="submit" name="action" value="save">Save changes</button>
|
|
</form>
|