Fix telegram page redirect: make first user admin and hide admin-only nav items from non-admins

Co-authored-by: xCyanGrizzly <53275238+xCyanGrizzly@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-04 18:55:02 +00:00
parent 0c789eabd6
commit 3704708970
4 changed files with 30 additions and 44 deletions

View File

@@ -21,12 +21,16 @@ export async function registerUser(input: unknown): Promise<ActionResult<{ id: s
const hashedPassword = await bcrypt.hash(parsed.data.password, 10);
// First user to register becomes ADMIN (self-hosted owner)
const userCount = await prisma.user.count();
const role = userCount === 0 ? "ADMIN" : "USER";
const user = await prisma.user.create({
data: {
name: parsed.data.name,
email: parsed.data.email,
hashedPassword,
role: "USER",
role,
settings: {
create: {
lowStockThreshold: 10,