favoritter/web/templates/pages/admin_users.html
Ole-Morten Duesund 13aec5be6e feat: add admin panel with user, tag, and signup management
Phase 4 — Admin Panel:
- Admin dashboard with user/fave/pending-request counts
- User management: create with temp password, reset password,
  enable/disable accounts (prevents self-disable)
- Tag management: rename and delete tags
- Signup request management: approve (creates user with
  must-reset-password) and reject pending requests
- Site settings: site name, description, signup mode
  (open/requests/closed)
- All admin routes require both login and admin role
- SignupRequest model and full store (create, list pending,
  approve with user creation, reject)
- SetMustResetPassword method on UserStore for admin password resets

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 16:09:30 +02:00

72 lines
2.6 KiB
HTML

{{define "head"}}
<meta name="robots" content="noindex">
{{end}}
{{define "content"}}
<h1>Brukere</h1>
<article>
<h2>Opprett ny bruker</h2>
<form method="POST" action="{{basePath}}/admin/users">
<input type="hidden" name="csrf_token" value="{{.CSRFToken}}">
<div class="grid">
<label for="username">
Brukernavn
<input type="text" id="username" name="username" required
pattern="[a-zA-Z0-9_-]+" minlength="2" maxlength="30">
</label>
<label for="role">
Rolle
<select id="role" name="role">
<option value="user">Bruker</option>
<option value="admin">Administrator</option>
</select>
</label>
</div>
<button type="submit">Opprett bruker</button>
<small>Brukeren vil få et midlertidig passord og må endre det ved første innlogging.</small>
</form>
</article>
{{with .Data}}
<table role="grid">
<thead>
<tr>
<th scope="col">Brukernavn</th>
<th scope="col">Visningsnavn</th>
<th scope="col">Rolle</th>
<th scope="col">Status</th>
<th scope="col">Opprettet</th>
<th scope="col">Handlinger</th>
</tr>
</thead>
<tbody>
{{range .Users}}
<tr {{if .Disabled}}class="disabled-row"{{end}}>
<td><a href="{{basePath}}/u/{{.Username}}">{{.Username}}</a></td>
<td>{{.DisplayName}}</td>
<td>{{.Role}}</td>
<td>
{{if .Disabled}}Deaktivert
{{else if .MustResetPassword}}Må endre passord
{{else}}Aktiv{{end}}
</td>
<td>{{.CreatedAt.Format "02.01.2006"}}</td>
<td>
<form method="POST" action="{{basePath}}/admin/users/{{.ID}}/reset-password" class="inline-form">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<button type="submit" class="outline secondary nav-button">Tilbakestill passord</button>
</form>
<form method="POST" action="{{basePath}}/admin/users/{{.ID}}/toggle-disabled" class="inline-form">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<button type="submit" class="outline {{if .Disabled}}primary{{else}}secondary{{end}} nav-button">
{{if .Disabled}}Aktiver{{else}}Deaktiver{{end}}
</button>
</form>
</td>
</tr>
{{end}}
</tbody>
</table>
{{end}}
{{end}}