Files

62 lines
4.2 KiB
HTML

{% extends "base.html" %}
{% import "components/macros.html" as ui %}
{% block title %}Edit User - Stick{% endblock %}
{% block content %}
<div class="grow flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
<div class="max-w-md w-full bg-[#1e293b]/40 backdrop-blur-xl border border-slate-900 rounded-3xl p-8 shadow-2xl relative overflow-hidden">
<div class="absolute top-0 left-0 w-full h-1 bg-sky-500"></div>
<div class="text-center mb-8">
<h2 class="text-3xl font-extrabold text-slate-100 tracking-tight">Edit User</h2>
<p class="mt-2 text-sm text-slate-400">Modify credentials and permissions for {{ user_to_edit.username }}</p>
</div>
{% if let Some(err) = error %}
<div class="mb-6 p-4 rounded-xl bg-rose-500/10 border border-rose-500/20 text-rose-400 text-sm flex items-start gap-2.5">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="w-5 h-5 shrink-0 mt-0.5">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m9-.75a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 3.75h.008v.008H12v-.008Z" />
</svg>
<span>{{ err }}</span>
</div>
{% endif %}
{% if let Some(msg) = success %}
<div class="mb-6 p-4 rounded-xl bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 text-sm flex items-start gap-2.5">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="w-5 h-5 shrink-0 mt-0.5">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75M21 12c0 1.268-.63 2.39-1.593 3.068a3.745 3.745 0 0 1-1.043 3.296 3.745 3.745 0 0 1-3.296 1.043A3.745 3.745 0 0 1 12 21c-1.268 0-2.39-.63-3.068-1.593a3.746 3.746 0 0 1-3.296-1.043 3.745 3.745 0 0 1-1.043-3.296A3.745 3.745 0 0 1 3 12c0-1.268.63-2.39 1.593-3.068a3.745 3.745 0 0 1 1.043-3.296 3.746 3.746 0 0 1 3.296-1.043A3.746 3.746 0 0 1 12 3c1.268 0 2.39.63 3.068 1.593a3.746 3.746 0 0 1 3.296 1.043 3.746 3.746 0 0 1 1.043 3.296A3.745 3.745 0 0 1 21 12Z" />
</svg>
<span>{{ msg }}</span>
</div>
{% endif %}
<form class="space-y-5" action="/auth/users/{{ user_to_edit.id.unwrap().to_hex() }}/edit" method="post">
{{ ui::text_input(id="username", name="username", label="Username", type="text", placeholder="Enter username", value=user_to_edit.username, required=true) }}
{{ ui::text_input(id="password", name="password", label="Reset Password (Leave blank to keep unchanged)", type="password", placeholder="••••••••", required=false) }}
<div class="flex items-center gap-2 py-1">
{% if user_to_edit.username == username %}
<!-- User is editing themselves: don't allow changing role to prevent lockout -->
<input type="hidden" name="is_admin" value="on">
<input type="checkbox" id="is_admin" class="w-4 h-4 rounded border-border bg-slate-900 text-indigo-600 opacity-50 cursor-not-allowed" checked disabled>
<label for="is_admin" class="text-xs font-semibold text-slate-500">Administrator <span class="text-[10px] text-sky-400/70 ml-1">(Cannot edit own role)</span></label>
{% else %}
<input type="checkbox" id="is_admin" name="is_admin" class="w-4 h-4 rounded border-border bg-[#0f172a] text-indigo-600 focus:ring-sky-500 focus:ring-offset-background" {% if user_to_edit.is_admin %}checked{% endif %}>
<label for="is_admin" class="text-xs font-semibold text-slate-400">Make Administrator</label>
{% endif %}
</div>
<div>
{{ ui::button(label="Save Changes", variant="indigo", type="submit", extra_class="w-full py-3.5 shadow-lg shadow-sky-500/10") }}
</div>
</form>
<div class="mt-6 text-center text-sm text-slate-400">
<a href="/auth/users" class="font-medium text-sky-400 hover:underline">← Back to Users</a>
</div>
</div>
</div>
{% endblock %}