mirror of
https://github.com/1f349/lavender.git
synced 2024-12-22 07:34:06 +00:00
Move manage apps and users forms into separate templates
This commit is contained in:
parent
befccd861f
commit
08096a4b98
72
pages/manage-apps-create.go.html
Normal file
72
pages/manage-apps-create.go.html
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>{{.ServiceName}}</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
|
<link rel="stylesheet" href="/assets/style.css">
|
||||||
|
<script>
|
||||||
|
window.addEventListener("load", function () {
|
||||||
|
selectText("app-secret");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Thanks again: https://stackoverflow.com/a/987376
|
||||||
|
function selectText(nodeId) {
|
||||||
|
const node = document.getElementById(nodeId);
|
||||||
|
|
||||||
|
if (document.body.createTextRange) {
|
||||||
|
const range = document.body.createTextRange();
|
||||||
|
range.moveToElementText(node);
|
||||||
|
range.select();
|
||||||
|
} else if (window.getSelection) {
|
||||||
|
const selection = window.getSelection();
|
||||||
|
const range = document.createRange();
|
||||||
|
range.selectNodeContents(node);
|
||||||
|
selection.removeAllRanges();
|
||||||
|
selection.addRange(range);
|
||||||
|
} else {
|
||||||
|
console.warn("Could not select text in node: Unsupported browser.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{{template "header.go.html" .}}
|
||||||
|
<main>
|
||||||
|
<form method="GET" action="/">
|
||||||
|
<button type="submit">Home</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<h2>Create Client Application</h2>
|
||||||
|
<form method="POST" action="/manage/apps">
|
||||||
|
<input type="hidden" name="action" value="create"/>
|
||||||
|
<input type="hidden" name="offset" value="{{.Offset}}"/>
|
||||||
|
<div>
|
||||||
|
<label for="field_name">Name:</label>
|
||||||
|
<input type="text" name="name" id="field_name" required/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="field_domain">Domain:</label>
|
||||||
|
<input type="text" name="domain" id="field_domain" required/>
|
||||||
|
</div>
|
||||||
|
{{if .IsAdmin}}
|
||||||
|
<div>
|
||||||
|
<label for="field_perms">Perms:</label>
|
||||||
|
<input type="text" name="perms" id="field_perms"/>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
<div>
|
||||||
|
<label for="field_public">Public: <input type="checkbox" name="public" id="field_public"/></label>
|
||||||
|
</div>
|
||||||
|
{{if .IsAdmin}}
|
||||||
|
<div>
|
||||||
|
<label for="field_sso">SSO: <input type="checkbox" name="sso" id="field_sso"/></label>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
<div>
|
||||||
|
<label for="field_active">Active: <input type="checkbox" name="active" id="field_active" checked/></label>
|
||||||
|
</div>
|
||||||
|
<button type="submit">Create</button>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
80
pages/manage-apps-edit.go.html
Normal file
80
pages/manage-apps-edit.go.html
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>{{.ServiceName}}</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
|
<link rel="stylesheet" href="/assets/style.css">
|
||||||
|
<script>
|
||||||
|
window.addEventListener("load", function () {
|
||||||
|
selectText("app-secret");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Thanks again: https://stackoverflow.com/a/987376
|
||||||
|
function selectText(nodeId) {
|
||||||
|
const node = document.getElementById(nodeId);
|
||||||
|
|
||||||
|
if (document.body.createTextRange) {
|
||||||
|
const range = document.body.createTextRange();
|
||||||
|
range.moveToElementText(node);
|
||||||
|
range.select();
|
||||||
|
} else if (window.getSelection) {
|
||||||
|
const selection = window.getSelection();
|
||||||
|
const range = document.createRange();
|
||||||
|
range.selectNodeContents(node);
|
||||||
|
selection.removeAllRanges();
|
||||||
|
selection.addRange(range);
|
||||||
|
} else {
|
||||||
|
console.warn("Could not select text in node: Unsupported browser.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{{template "header.go.html" .}}
|
||||||
|
<main>
|
||||||
|
<form method="GET" action="/">
|
||||||
|
<button type="submit">Home</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<h2>Edit Client Application</h2>
|
||||||
|
<form method="POST" action="/manage/apps">
|
||||||
|
<input type="hidden" name="action" value="edit"/>
|
||||||
|
<input type="hidden" name="offset" value="{{.Offset}}"/>
|
||||||
|
<input type="hidden" name="subject" value="{{.EditApp.Subject}}"/>
|
||||||
|
<div>
|
||||||
|
<label>ID: {{.EditApp.Subject}}</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="field_name">Name:</label>
|
||||||
|
<input type="text" name="name" id="field_name" value="{{.EditApp.Name}}" required/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="field_domain">Domain:</label>
|
||||||
|
<input type="text" name="domain" id="field_domain" value="{{.EditApp.Domain}}" required/>
|
||||||
|
</div>
|
||||||
|
{{if .IsAdmin}}
|
||||||
|
<div>
|
||||||
|
<label for="field_perms">Perms:</label>
|
||||||
|
<input type="text" name="perms" id="field_perms" value="{{.EditApp.Perms}}" size="100"/>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
<div>
|
||||||
|
<label for="field_public">Public: <input type="checkbox" name="public" id="field_public" {{if .EditApp.Public}}checked{{end}}/></label>
|
||||||
|
</div>
|
||||||
|
{{if .IsAdmin}}
|
||||||
|
<div>
|
||||||
|
<label for="field_sso">SSO: <input type="checkbox" name="sso" id="field_sso" {{if .EditApp.Sso}}checked{{end}}/></label>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
<div>
|
||||||
|
<label for="field_active">Active: <input type="checkbox" name="active" id="field_active" {{if .EditApp.Active}}checked{{end}}/></label>
|
||||||
|
</div>
|
||||||
|
<button type="submit">Edit</button>
|
||||||
|
</form>
|
||||||
|
<form method="GET" action="/manage/apps">
|
||||||
|
<input type="hidden" name="offset" value="{{.Offset}}"/>
|
||||||
|
<button type="submit">Cancel</button>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>{{.ServiceName}}</title>
|
<title>{{.ServiceName}}</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
<link rel="stylesheet" href="/assets/style.css">
|
<link rel="stylesheet" href="/assets/style.css">
|
||||||
<script>
|
<script>
|
||||||
window.addEventListener("load", function () {
|
window.addEventListener("load", function () {
|
||||||
@ -40,124 +40,53 @@
|
|||||||
<div>New application secret: <span id="app-secret">{{.NewAppSecret}}</span> for {{.NewAppName}}</div>
|
<div>New application secret: <span id="app-secret">{{.NewAppSecret}}</span> for {{.NewAppName}}</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if .EditApp}}
|
<h2>Manage Client Applications</h2>
|
||||||
<h2>Edit Client Application</h2>
|
<form method="GET" action="/manage/apps/create">
|
||||||
<form method="POST" action="/manage/apps">
|
<button type="submit">New Client Application</button>
|
||||||
<input type="hidden" name="action" value="edit"/>
|
</form>
|
||||||
<input type="hidden" name="offset" value="{{.Offset}}"/>
|
{{if eq (len .Apps) 0}}
|
||||||
<input type="hidden" name="subject" value="{{.EditApp.Subject}}"/>
|
<div>No client applications found</div>
|
||||||
<div>
|
|
||||||
<label>ID: {{.EditApp.Subject}}</label>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="field_name">Name:</label>
|
|
||||||
<input type="text" name="name" id="field_name" value="{{.EditApp.Name}}" required/>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="field_domain">Domain:</label>
|
|
||||||
<input type="text" name="domain" id="field_domain" value="{{.EditApp.Domain}}" required/>
|
|
||||||
</div>
|
|
||||||
{{if .IsAdmin}}
|
|
||||||
<div>
|
|
||||||
<label for="field_perms">Perms:</label>
|
|
||||||
<input type="text" name="perms" id="field_perms" value="{{.EditApp.Perms}}" size="100"/>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
<div>
|
|
||||||
<label for="field_public">Public: <input type="checkbox" name="public" id="field_public" {{if .EditApp.Public}}checked{{end}}/></label>
|
|
||||||
</div>
|
|
||||||
{{if .IsAdmin}}
|
|
||||||
<div>
|
|
||||||
<label for="field_sso">SSO: <input type="checkbox" name="sso" id="field_sso" {{if .EditApp.SSO}}checked{{end}}/></label>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
<div>
|
|
||||||
<label for="field_active">Active: <input type="checkbox" name="active" id="field_active" {{if .EditApp.Active}}checked{{end}}/></label>
|
|
||||||
</div>
|
|
||||||
<button type="submit">Edit</button>
|
|
||||||
</form>
|
|
||||||
<form method="GET" action="/manage/apps">
|
|
||||||
<input type="hidden" name="offset" value="{{.Offset}}"/>
|
|
||||||
<button type="submit">Cancel</button>
|
|
||||||
</form>
|
|
||||||
{{else}}
|
{{else}}
|
||||||
<h2>Manage Client Applications</h2>
|
<table>
|
||||||
{{if eq (len .Apps) 0}}
|
<thead>
|
||||||
<div>No client applications found</div>
|
<tr>
|
||||||
{{else}}
|
<th>ID</th>
|
||||||
<table>
|
<th>Name</th>
|
||||||
<thead>
|
<th>Domain</th>
|
||||||
|
<th>Perms</th>
|
||||||
|
<th>SSO</th>
|
||||||
|
<th>Active</th>
|
||||||
|
<th>Owner</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{range .Apps}}
|
||||||
<tr>
|
<tr>
|
||||||
<th>ID</th>
|
<td>{{.Subject}}</td>
|
||||||
<th>Name</th>
|
<td>{{.Name}}</td>
|
||||||
<th>Domain</th>
|
<td>{{.Domain}}</td>
|
||||||
<th>Perms</th>
|
<td>{{.Perms}}</td>
|
||||||
<th>SSO</th>
|
<td>{{.Sso}}</td>
|
||||||
<th>Active</th>
|
<td>{{.Active}}</td>
|
||||||
<th>Owner</th>
|
<td>{{.Owner}}</td>
|
||||||
<th>Actions</th>
|
<td>
|
||||||
|
<form method="GET" action="/manage/apps">
|
||||||
|
<input type="hidden" name="offset" value="{{$.Offset}}"/>
|
||||||
|
<input type="hidden" name="edit" value="{{.Subject}}"/>
|
||||||
|
<button type="submit">Edit</button>
|
||||||
|
</form>
|
||||||
|
<form method="POST" action="/manage/apps?offset={{$.Offset}}">
|
||||||
|
<input type="hidden" name="action" value="secret"/>
|
||||||
|
<input type="hidden" name="offset" value="{{$.Offset}}"/>
|
||||||
|
<input type="hidden" name="subject" value="{{.Subject}}"/>
|
||||||
|
<button type="submit">Reset Secret</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{{range .Apps}}
|
|
||||||
<tr>
|
|
||||||
<td>{{.Subject}}</td>
|
|
||||||
<td>{{.Name}}</td>
|
|
||||||
<td>{{.Domain}}</td>
|
|
||||||
<td>{{.Perms}}</td>
|
|
||||||
<td>{{.SSO}}</td>
|
|
||||||
<td>{{.Active}}</td>
|
|
||||||
<td>{{.Owner}}</td>
|
|
||||||
<td>
|
|
||||||
<form method="GET" action="/manage/apps">
|
|
||||||
<input type="hidden" name="offset" value="{{$.Offset}}"/>
|
|
||||||
<input type="hidden" name="edit" value="{{.Subject}}"/>
|
|
||||||
<button type="submit">Edit</button>
|
|
||||||
</form>
|
|
||||||
<form method="POST" action="/manage/apps?offset={{$.Offset}}">
|
|
||||||
<input type="hidden" name="action" value="secret"/>
|
|
||||||
<input type="hidden" name="offset" value="{{$.Offset}}"/>
|
|
||||||
<input type="hidden" name="subject" value="{{.Subject}}"/>
|
|
||||||
<button type="submit">Reset Secret</button>
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{end}}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
<h2>Create Client Application</h2>
|
|
||||||
<form method="POST" action="/manage/apps">
|
|
||||||
<input type="hidden" name="action" value="create"/>
|
|
||||||
<input type="hidden" name="offset" value="{{.Offset}}"/>
|
|
||||||
<div>
|
|
||||||
<label for="field_name">Name:</label>
|
|
||||||
<input type="text" name="name" id="field_name" required/>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="field_domain">Domain:</label>
|
|
||||||
<input type="text" name="domain" id="field_domain" required/>
|
|
||||||
</div>
|
|
||||||
{{if .IsAdmin}}
|
|
||||||
<div>
|
|
||||||
<label for="field_perms">Perms:</label>
|
|
||||||
<input type="text" name="perms" id="field_perms"/>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
{{end}}
|
||||||
<div>
|
</tbody>
|
||||||
<label for="field_public">Public: <input type="checkbox" name="public" id="field_public"/></label>
|
</table>
|
||||||
</div>
|
|
||||||
{{if .IsAdmin}}
|
|
||||||
<div>
|
|
||||||
<label for="field_sso">SSO: <input type="checkbox" name="sso" id="field_sso"/></label>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
<div>
|
|
||||||
<label for="field_active">Active: <input type="checkbox" name="active" id="field_active" checked/></label>
|
|
||||||
</div>
|
|
||||||
<button type="submit">Create</button>
|
|
||||||
</form>
|
|
||||||
{{end}}
|
{{end}}
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
|
38
pages/manage-users-edit.go.html
Normal file
38
pages/manage-users-edit.go.html
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>{{.ServiceName}}</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
|
<link rel="stylesheet" href="/assets/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{{template "header.go.html" .}}
|
||||||
|
<main>
|
||||||
|
<form method="GET" action="/">
|
||||||
|
<button type="submit">Home</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<h2>Edit User</h2>
|
||||||
|
<form method="POST" action="/manage/users">
|
||||||
|
<input type="hidden" name="action" value="edit"/>
|
||||||
|
<input type="hidden" name="offset" value="{{.Offset}}"/>
|
||||||
|
<div>
|
||||||
|
<label for="field_subject">Subject:</label>
|
||||||
|
<input type="text" name="subject" id="field_subject" value="{{.EditUser.Subject}}" required/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="field_roles">Roles:</label>
|
||||||
|
<input type="text" name="roles" id="field_roles" value="{{.EditUser.Roles}}" size="100"/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="field_active">Active: <input type="checkbox" name="active" id="field_active" checked/></label>
|
||||||
|
</div>
|
||||||
|
<button type="submit">Edit</button>
|
||||||
|
</form>
|
||||||
|
<form method="GET" action="/manage/users">
|
||||||
|
<input type="hidden" name="offset" value="{{.Offset}}"/>
|
||||||
|
<button type="submit">Cancel</button>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>{{.ServiceName}}</title>
|
<title>{{.ServiceName}}</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
<link rel="stylesheet" href="/assets/style.css">
|
<link rel="stylesheet" href="/assets/style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -12,83 +12,59 @@
|
|||||||
<button type="submit">Home</button>
|
<button type="submit">Home</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{{if .EditUser}}
|
<h2>Manage Users</h2>
|
||||||
<h2>Edit User</h2>
|
{{if eq (len .Users) 0}}
|
||||||
<form method="POST" action="/manage/users">
|
<div>No users found, this is definitely a bug.</div>
|
||||||
<input type="hidden" name="action" value="edit"/>
|
{{else}}
|
||||||
<input type="hidden" name="offset" value="{{.Offset}}"/>
|
<table>
|
||||||
<div>
|
<thead>
|
||||||
<label for="field_subject">Subject:</label>
|
<tr>
|
||||||
<input type="text" name="subject" id="field_subject" value="{{.EditUser.Subject}}" required/>
|
<th>Subject</th>
|
||||||
</div>
|
<th>Email</th>
|
||||||
<div>
|
<th>Email Verified</th>
|
||||||
<label for="field_roles">Roles:</label>
|
<th>Roles</th>
|
||||||
<input type="text" name="roles" id="field_roles" value="{{.EditUser.Roles}}" size="100"/>
|
<th>Last Updated</th>
|
||||||
</div>
|
<th>Active</th>
|
||||||
<div>
|
<th>Actions</th>
|
||||||
<label for="field_active">Active: <input type="checkbox" name="active" id="field_active" checked/></label>
|
</tr>
|
||||||
</div>
|
</thead>
|
||||||
<button type="submit">Edit</button>
|
<tbody>
|
||||||
</form>
|
{{range .Users}}
|
||||||
|
<tr>
|
||||||
|
<td>{{.Subject}}</td>
|
||||||
|
<th>
|
||||||
|
{{if $.EmailShow}}
|
||||||
|
<span>{{.Email}}</span>
|
||||||
|
{{else}}
|
||||||
|
<span>{{emailHide .Email}}</span>
|
||||||
|
{{end}}
|
||||||
|
</th>
|
||||||
|
<th>{{.EmailVerified}}</th>
|
||||||
|
<th>{{.Roles}}</th>
|
||||||
|
<th>{{.UpdatedAt}}</th>
|
||||||
|
<td>{{.Active}}</td>
|
||||||
|
<td>
|
||||||
|
<form method="GET" action="/manage/users">
|
||||||
|
<input type="hidden" name="offset" value="{{$.Offset}}"/>
|
||||||
|
<input type="hidden" name="edit" value="{{.Subject}}"/>
|
||||||
|
<button type="submit">Edit</button>
|
||||||
|
</form>
|
||||||
|
<form method="POST" action="/reset-password">
|
||||||
|
<input type="hidden" name="email" value="{{.Email}}"/>
|
||||||
|
<button type="submit">Send Reset Password Email</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{end}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
<form method="GET" action="/manage/users">
|
<form method="GET" action="/manage/users">
|
||||||
<input type="hidden" name="offset" value="{{.Offset}}"/>
|
<input type="hidden" name="offset" value="{{.Offset}}"/>
|
||||||
<button type="submit">Cancel</button>
|
{{if not .EmailShow}}
|
||||||
|
<input type="hidden" name="show-email"/>
|
||||||
|
{{end}}
|
||||||
|
<button type="submit">{{if .EmailShow}}Hide Email Addresses{{else}}Show email addresses{{end}}</button>
|
||||||
</form>
|
</form>
|
||||||
{{else}}
|
|
||||||
<h2>Manage Users</h2>
|
|
||||||
{{if eq (len .Users) 0}}
|
|
||||||
<div>No users found, this is definitely a bug.</div>
|
|
||||||
{{else}}
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Subject</th>
|
|
||||||
<th>Email</th>
|
|
||||||
<th>Email Verified</th>
|
|
||||||
<th>Roles</th>
|
|
||||||
<th>Last Updated</th>
|
|
||||||
<th>Active</th>
|
|
||||||
<th>Actions</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{{range .Users}}
|
|
||||||
<tr>
|
|
||||||
<td>{{.Subject}}</td>
|
|
||||||
<th>
|
|
||||||
{{if $.EmailShow}}
|
|
||||||
<span>{{.Email}}</span>
|
|
||||||
{{else}}
|
|
||||||
<span>{{emailHide .Email}}</span>
|
|
||||||
{{end}}
|
|
||||||
</th>
|
|
||||||
<th>{{.EmailVerified}}</th>
|
|
||||||
<th>{{.Roles}}</th>
|
|
||||||
<th>{{.UpdatedAt}}</th>
|
|
||||||
<td>{{.Active}}</td>
|
|
||||||
<td>
|
|
||||||
<form method="GET" action="/manage/users">
|
|
||||||
<input type="hidden" name="offset" value="{{$.Offset}}"/>
|
|
||||||
<input type="hidden" name="edit" value="{{.Subject}}"/>
|
|
||||||
<button type="submit">Edit</button>
|
|
||||||
</form>
|
|
||||||
<form method="POST" action="/reset-password">
|
|
||||||
<input type="hidden" name="email" value="{{.Email}}"/>
|
|
||||||
<button type="submit">Send Reset Password Email</button>
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{end}}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<form method="GET" action="/manage/users">
|
|
||||||
<input type="hidden" name="offset" value="{{.Offset}}"/>
|
|
||||||
{{if not .EmailShow}}
|
|
||||||
<input type="hidden" name="show-email"/>
|
|
||||||
{{end}}
|
|
||||||
<button type="submit">{{if .EmailShow}}Hide Email Addresses{{else}}Show email addresses{{end}}</button>
|
|
||||||
</form>
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
{{end}}
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
|
@ -63,6 +63,25 @@ func (h *HttpServer) ManageAppsGet(rw http.ResponseWriter, req *http.Request, _
|
|||||||
pages.RenderPageTemplate(rw, "manage-apps", m)
|
pages.RenderPageTemplate(rw, "manage-apps", m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *HttpServer) ManageAppsCreateGet(rw http.ResponseWriter, _ *http.Request, _ httprouter.Params, auth UserAuth) {
|
||||||
|
var roles string
|
||||||
|
if h.DbTx(rw, func(tx *database.Tx) (err error) {
|
||||||
|
roles, err = tx.GetUserRoles(auth.Subject)
|
||||||
|
return
|
||||||
|
}) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
m := map[string]any{
|
||||||
|
"ServiceName": h.conf.ServiceName,
|
||||||
|
"IsAdmin": HasRole(roles, "lavender:admin"),
|
||||||
|
}
|
||||||
|
|
||||||
|
rw.Header().Set("Content-Type", "text/html")
|
||||||
|
rw.WriteHeader(http.StatusOK)
|
||||||
|
pages.RenderPageTemplate(rw, "manage-apps-create", m)
|
||||||
|
}
|
||||||
|
|
||||||
func (h *HttpServer) ManageAppsPost(rw http.ResponseWriter, req *http.Request, _ httprouter.Params, auth UserAuth) {
|
func (h *HttpServer) ManageAppsPost(rw http.ResponseWriter, req *http.Request, _ httprouter.Params, auth UserAuth) {
|
||||||
err := req.ParseForm()
|
err := req.ParseForm()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -152,6 +152,7 @@ func NewHttpServer(conf Conf, db *database.DB, signingKey mjwt.Signer) *http.Ser
|
|||||||
|
|
||||||
// management pages
|
// management pages
|
||||||
r.GET("/manage/apps", hs.RequireAuthentication(hs.ManageAppsGet))
|
r.GET("/manage/apps", hs.RequireAuthentication(hs.ManageAppsGet))
|
||||||
|
r.GET("/manage/apps/create", hs.RequireAuthentication(hs.ManageAppsCreateGet))
|
||||||
r.POST("/manage/apps", hs.RequireAuthentication(hs.ManageAppsPost))
|
r.POST("/manage/apps", hs.RequireAuthentication(hs.ManageAppsPost))
|
||||||
r.GET("/manage/users", hs.RequireAdminAuthentication(hs.ManageUsersGet))
|
r.GET("/manage/users", hs.RequireAdminAuthentication(hs.ManageUsersGet))
|
||||||
r.POST("/manage/users", hs.RequireAdminAuthentication(hs.ManageUsersPost))
|
r.POST("/manage/users", hs.RequireAdminAuthentication(hs.ManageUsersPost))
|
||||||
|
Loading…
Reference in New Issue
Block a user