Skip to content
This repository was archived by the owner on Jul 12, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmd/server/assets/admin/_nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
</li>

<li class="nav-item">
<a class="nav-link{{if .currentPath.IsDir "/admin/users"}} active{{end}}" href="/admin/users">System admins</a>
<a class="nav-link{{if .currentPath.IsDir "/admin/superusers"}} active{{end}}" href="/admin/superusers">System admins</a>
</li>

<li class="nav-item">
<a class="nav-link{{if .currentPath.IsDir "/admin/users"}} active{{end}}" href="/admin/users">Users</a>
</li>

<li class="nav-item">
Expand Down
65 changes: 65 additions & 0 deletions cmd/server/assets/admin/superusers/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{{define "admin/superusers/index"}}

{{$currentUser := .currentUser}}
{{$admins := .admins}}

<!doctype html>
<html lang="en">
<head>
{{template "head" .}}
</head>

<body class="tab-content">
{{template "admin/navbar" .}}

<main role="main" class="container">
{{template "flash" .}}

<div class="card mb-3 shadow-sm">
<div class="card-header">System admins</div>
<div class="card-body">
<div class="clearfix mb-3">
<a class="btn btn-outline-secondary btn-sm float-right" href="/admin/superusers/new">
<span class="oi oi-plus" aria-hidden="true"></span>
New system admin
</a>
</div>

<div class="table-responsive">
<table class="table table-bordered table-striped mb-0">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col" width="300">Email</th>
<th scope="col" width="40"></th>
</tr>
</thead>
<tbody>
{{range $admins}}
<tr>
<td>{{.Name}}</td>
<td>{{.Email}}</td>
<td class="text-center">
{{- /* cannot delete yourself */ -}}
{{if not (eq .ID $currentUser.ID)}}
<a href="/admin/superusers/{{.ID}}"
class="d-block text-danger"
data-method="DELETE"
data-confirm="Are you sure you want to remove this system admin?"
data-toggle="tooltip"
title="Remove this system admin">
<span class="oi oi-trash" aria-hidden="true"></span>
</a>
{{end}}
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
</div>
</div>
</main>
</body>
</html>
{{end}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{define "admin/users/new"}}
{{define "admin/superusers/new"}}

{{$user := .user}}

Expand All @@ -23,7 +23,7 @@ <h1>New system admin</h1>
<div class="card mb-3 shadow-sm">
<div class="card-header">System admin details</div>
<div class="card-body">
<form method="POST" action="/admin/users">
<form method="POST" action="/admin/superusers">
{{ .csrfField }}

<div class="form-label-group">
Expand Down
31 changes: 20 additions & 11 deletions cmd/server/assets/admin/users/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{define "admin/users/index"}}

{{$currentUser := .currentUser}}
{{$admins := .admins}}
{{$users := .users}}

<!doctype html>
<html lang="en">
Expand All @@ -16,14 +16,21 @@
{{template "flash" .}}

<div class="card mb-3 shadow-sm">
<div class="card-header">System admins</div>
<div class="card-header">Users</div>
<div class="card-body">
<form method="GET" action="/admin/users" id="search-form">
<div class="input-group">
<span class="input-group-prepend">
<div class="input-group-text bg-transparent">
<span class="oi oi-magnifying-glass" aria-hidden="true"></span>
</div>
</span>
<input type="search" name="q" id="search" value="{{.query}}" placeholder="Search"
autocomplete="off" class="form-control" />
</div>
</form>
</div>
<div class="card-body">
<div class="clearfix mb-3">
<a class="btn btn-outline-secondary btn-sm float-right" href="/admin/users/new">
<span class="oi oi-plus" aria-hidden="true"></span>
New system admin
</a>
</div>

<div class="table-responsive">
<table class="table table-bordered table-striped mb-0">
Expand All @@ -35,7 +42,7 @@
</tr>
</thead>
<tbody>
{{range $admins}}
{{range $users}}
<tr>
<td>{{.Name}}</td>
<td>{{.Email}}</td>
Expand All @@ -45,9 +52,9 @@
<a href="/admin/users/{{.ID}}"
class="d-block text-danger"
data-method="DELETE"
data-confirm="Are you sure you want to remove this system admin?"
data-confirm="Are you sure you want to delete this user? This will prevent access to all realms system-wide."
data-toggle="tooltip"
title="Remove this system admin">
title="Delete this user">
<span class="oi oi-trash" aria-hidden="true"></span>
</a>
{{end}}
Expand All @@ -59,6 +66,8 @@
</div>
</div>
</div>

{{template "shared/pagination" .}}
</main>
</body>
</html>
Expand Down
9 changes: 6 additions & 3 deletions internal/routes/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,13 @@ func Server(
adminSub.Handle("/realms/{id:[0-9]+}/leave", adminController.HandleRealmsLeave()).Methods("PATCH")
adminSub.Handle("/realms/{id:[0-9]+}", adminController.HandleRealmsUpdate()).Methods("PATCH")

adminSub.Handle("/superusers", adminController.HandleSuperUsersIndex()).Methods("GET")
adminSub.Handle("/superusers", adminController.HandleSuperUsersCreate()).Methods("POST")
adminSub.Handle("/superusers/new", adminController.HandleSuperUsersCreate()).Methods("GET")
adminSub.Handle("/superusers/{id:[0-9]+}", adminController.HandleSuperUsersDelete()).Methods("DELETE")

adminSub.Handle("/users", adminController.HandleUsersIndex()).Methods("GET")
adminSub.Handle("/users", adminController.HandleUsersCreate()).Methods("POST")
adminSub.Handle("/users/new", adminController.HandleUsersCreate()).Methods("GET")
adminSub.Handle("/users/{id:[0-9]+}", adminController.HandleUsersDelete()).Methods("DELETE")
adminSub.Handle("/users/{id:[0-9]+}", adminController.HandleUserDelete()).Methods("DELETE")

adminSub.Handle("/mobileapps", adminController.HandleMobileAppsShow()).Methods("GET")
adminSub.Handle("/sms", adminController.HandleSMSUpdate()).Methods("GET", "POST")
Expand Down
Loading