103 lines
4.2 KiB
Plaintext
103 lines
4.2 KiB
Plaintext
<section>
|
|
<div class="flex between center">
|
|
<h1>Admin · Users</h1>
|
|
<a class="btn" href="/admin">Tickets</a>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h3>Grant admin by email</h3>
|
|
<form method="post" action="/admin/users/grant-admin" class="flex">
|
|
<label style="flex:1">Name (optional)
|
|
<input type="text" name="name" placeholder="Name" />
|
|
</label>
|
|
<label style="flex:1">Email
|
|
<input type="email" name="email" required placeholder="user@example.com" />
|
|
</label>
|
|
<div style="align-self:flex-end">
|
|
<button type="submit" class="btn primary">Grant admin</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<% if (!users || users.length === 0) { %>
|
|
<p>No users found.</p>
|
|
<% } else { %>
|
|
<div class="table">
|
|
<div class="row head">
|
|
<div>Name</div>
|
|
<div>Email · Auth</div>
|
|
<div>Role</div>
|
|
<div>Created</div>
|
|
<div></div>
|
|
</div>
|
|
<% users.forEach(u => { %>
|
|
<div class="row">
|
|
<div><%= (u.name && u.name.trim()) ? u.name : '—' %></div>
|
|
<div class="small muted">
|
|
<%= u.email || '—' %>
|
|
<% if (typeof u.has_google !== 'undefined' || typeof u.has_password !== 'undefined') { %>
|
|
·
|
|
<% if (u.has_google && u.has_password) { %>
|
|
<span class="badge">Google + Email</span>
|
|
<% } else if (u.has_google) { %>
|
|
<span class="badge">Google</span>
|
|
<% } else if (u.has_password) { %>
|
|
<span class="badge">Email</span>
|
|
<% } else { %>
|
|
<span class="badge">No login set</span>
|
|
<% } %>
|
|
·
|
|
<% if (u.email_verified) { %>
|
|
<span class="badge verified" title="Email verified">Verified</span>
|
|
<% } else { %>
|
|
<span class="badge unverified" title="Email not yet verified">Unverified</span>
|
|
<% } %>
|
|
<% } %>
|
|
</div>
|
|
<div>
|
|
<% if (u.role === 'admin') { %>
|
|
<span class="badge admin">admin</span>
|
|
<% } else { %>
|
|
<span class="badge"><%= u.role %></span>
|
|
<% } %>
|
|
<% if (u.banned) { %>
|
|
<span class="badge banned" title="This user is banned">banned</span>
|
|
<% } %>
|
|
</div>
|
|
<div class="small muted"><%= u.created_at || '' %></div>
|
|
<div class="actions">
|
|
<% if (u.role !== 'admin') { %>
|
|
<form method="post" action="/admin/users/<%= u.id %>/make-admin" onsubmit="return confirm('Grant admin rights to <%= u.email %>?')">
|
|
<button type="submit" class="btn">Make admin</button>
|
|
</form>
|
|
<% } else { %>
|
|
<% if (!currentUser || currentUser.id !== u.id) { %>
|
|
<form method="post" action="/admin/users/<%= u.id %>/unadmin" onsubmit="return confirm('Remove admin rights from <%= u.email %>?')">
|
|
<button type="submit" class="btn danger">Remove admin</button>
|
|
</form>
|
|
<% } else { %>
|
|
<span class="small muted">(You)</span>
|
|
<% } %>
|
|
<% } %>
|
|
|
|
<% if (!currentUser || currentUser.id !== u.id) { %>
|
|
<% if (u.banned) { %>
|
|
<form method="post" action="/admin/users/<%= u.id %>/unban" onsubmit="return confirm('Unban <%= u.email %>?')">
|
|
<button type="submit" class="btn">Unban</button>
|
|
</form>
|
|
<% } else { %>
|
|
<form method="post" action="/admin/users/<%= u.id %>/ban" onsubmit="return confirm('Ban <%= u.email %>? They will be unable to sign in.')">
|
|
<button type="submit" class="btn danger">Ban</button>
|
|
</form>
|
|
<% } %>
|
|
<form method="post" action="/admin/users/<%= u.id %>/delete" onsubmit="return confirm('Permanently delete <%= u.email %>? All their tickets and responses will be removed. This cannot be undone.')">
|
|
<button type="submit" class="btn danger">Delete user</button>
|
|
</form>
|
|
<% } %>
|
|
</div>
|
|
</div>
|
|
<% }) %>
|
|
</div>
|
|
<% } %>
|
|
</section>
|