111 lines
3.8 KiB
Plaintext
111 lines
3.8 KiB
Plaintext
@page "/Admin/ACL/{id:int}/Edit"
|
|
@using Authinator.Backend.Utils
|
|
@using Authinator.Backend.Database
|
|
@using Authinator.Backend.Database.Tables
|
|
@using System.Web
|
|
@using Microsoft.EntityFrameworkCore
|
|
@model AdminEditACLModel
|
|
@{
|
|
ViewData["Title"] = "Edit ACL - Admin";
|
|
|
|
var acl = Model.ModelACL;
|
|
var db = new DatabaseContext();
|
|
|
|
var statusIcon = acl.Enabled ? "bi-check-circle-fill" : "bi-dash-circle-dotted";
|
|
var statusText = acl.Enabled ? "ACL is currently enabled" : "ACL is currently disabled";
|
|
}
|
|
|
|
<form method="POST" class="border rounded px-3 py-3">
|
|
<div class="mb-3 fs-4">
|
|
Editing ACL: <span class="bg-body-secondary rounded ms-1 px-2 py-1 fw-light">@acl.Name</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="name" class="form-label">ACL name</label>
|
|
<input class="form-control" type="text" id="name" name="name" value="@acl.Name" required/>
|
|
</div>
|
|
<div class="mb-2">
|
|
<div class="form-check">
|
|
@if (acl.Enabled) {
|
|
<input class="form-check-input" type="checkbox" id="enabled" name="enabled" checked>
|
|
}
|
|
else {
|
|
<input class="form-check-input" type="checkbox" id="enabled" name="enabled">
|
|
}
|
|
<label for="enabled" class="form-label">Enable ACL</label>
|
|
</div>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="target" class="form-label">Target</label>
|
|
<input class="form-control" type="text" id="target" name="target" placeholder="*.domain.tld" value="@acl.Target" required/>
|
|
</div>
|
|
<div class="mb-2">
|
|
<div class="form-check">
|
|
@if (acl.TargetIsRegex) {
|
|
<input class="form-check-input" type="checkbox" id="target-is-regex" name="target-is-regex" checked>
|
|
}
|
|
else {
|
|
<input class="form-check-input" type="checkbox" id="target-is-regex" name="target-is-regex">
|
|
}
|
|
<label for="target-is-regex" class="form-label">Regex matching</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Allow groups?</label>
|
|
@foreach (var group in db.Groups) {
|
|
<div class="form-check">
|
|
@if (acl.Groups.Any(p => p == group)) {
|
|
<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>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Allow users?</label>
|
|
@foreach (var user in db.Users) {
|
|
<div class="form-check">
|
|
@if (acl.Users.Any(p => p == user)) {
|
|
<input class="form-check-input" type="checkbox" id="check-user-@user.Id" name="user" value="@user.Id" checked>
|
|
}
|
|
else {
|
|
<input class="form-check-input" type="checkbox" id="check-user-@user.Id" name="user" value="@user.Id">
|
|
}
|
|
<label class="form-check-label" for="check-user-@user.Id">
|
|
@user.Username <span class="px-1 bg-body-secondary">@user.Reference</span>
|
|
</label>
|
|
</div>
|
|
}
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Allow networks?</label>
|
|
@foreach (var network in db.Networks) {
|
|
<div class="form-check">
|
|
@if (acl.Networks.Any(p => p == network)) {
|
|
<input class="form-check-input" type="checkbox" id="check-network-@network.Id" name="user" value="@network.Id" checked>
|
|
}
|
|
else {
|
|
<input class="form-check-input" type="checkbox" id="check-network-@network.Id" name="user" value="@network.Id">
|
|
}
|
|
<label class="form-check-label" for="check-network-@network.Id">
|
|
@network.Name <span class="px-1 bg-body-secondary">@network.Subnet.ToString()</span>
|
|
</label>
|
|
</div>
|
|
}
|
|
</div>
|
|
|
|
<button class="btn btn-primary" type="submit" name="action" value="save">Save changes</button>
|
|
</form>
|