Add manual user creation in admin panel

- Server action createUser() with bcrypt password hash + Account record
- Form with name, email, password (show/hide + generate), role, emailVerified toggle
- Optional welcome email toggle (bypasses auto-hook for admin-created users)
- /admin/users/new page with breadcrumb navigation
- After creation, redirects to the new user's profile page
- "Добавить пользователя" button on the users list page

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-08 12:36:52 +05:00
parent 58a61d6f04
commit 99c143d670
4 changed files with 322 additions and 3 deletions
+13 -3
View File
@@ -1,6 +1,7 @@
import { prisma } from "@/lib/prisma";
import { Badge } from "@/components/ui/badge";
import Link from "next/link";
import { UserPlus } from "lucide-react";
const roleLabel: Record<string, string> = {
admin: "Администратор",
@@ -22,9 +23,18 @@ export default async function UsersPage() {
return (
<div className="p-8">
<div className="mb-6">
<h1 className="text-2xl font-semibold text-slate-800">Пользователи</h1>
<p className="text-slate-500 text-sm mt-0.5">{users.length} пользователей</p>
<div className="mb-6 flex items-center justify-between">
<div>
<h1 className="text-2xl font-semibold text-slate-800">Пользователи</h1>
<p className="text-slate-500 text-sm mt-0.5">{users.length} пользователей</p>
</div>
<Link
href="/admin/users/new"
className="btn-aubade btn-aubade-accent flex items-center gap-1.5 px-4 py-2 text-sm"
>
<UserPlus size={14} />
Добавить пользователя
</Link>
</div>
<div className="bg-white border border-slate-200 rounded-2xl overflow-hidden">