Skip to content

feat: add multiple admin support for rooms#43

Open
buildingvibes wants to merge 1 commit into
Fahad-Dezloper:mainfrom
buildingvibes:feat/multiple-admin-support
Open

feat: add multiple admin support for rooms#43
buildingvibes wants to merge 1 commit into
Fahad-Dezloper:mainfrom
buildingvibes:feat/multiple-admin-support

Conversation

@buildingvibes
Copy link
Copy Markdown

Summary

Resolves #27 — Multiple Admin Support

This PR introduces a full multiple admin system for Crowdify rooms:

  • OWNER role: Room creators are now assigned an OWNER role (distinct from ADMIN), ensuring they can never be demoted and retain full control
  • Admin check via RoomUser: The isAdmin check in /api/room/[roomId] now queries RoomUser.role instead of comparing against room.adminId, enabling multiple admins per room
  • Promote/Demote API (/api/room/[roomId]/admins): Room owners can promote any room member to ADMIN or demote them back to USER. Owners cannot be modified.
  • Room join tracking (/api/room/[roomId]/join): When users enter a room, a RoomUser record is created (upsert), so all participants are tracked for role management
  • Admin Panel UI: A new AdminPanel modal component (accessible via "Manage" button in the top bar) shows all room members with their roles and allows the owner to promote/demote users with a single click
  • Prisma migration: Adds the OWNER value to the Role enum and migrates existing room creators from ADMIN to OWNER

Changes

File Change
prisma/schema.prisma Added OWNER to Role enum
prisma/migrations/20250212000000_multiple_admin_support/ Migration for OWNER enum + data migration
app/api/room/create/route.ts Room creator gets OWNER role instead of ADMIN
app/api/room/[roomId]/route.ts Admin check uses RoomUser.role, returns isOwner flag
app/api/room/[roomId]/admins/route.ts New — GET lists members, POST promotes/demotes
app/api/room/[roomId]/join/route.ts New — POST creates RoomUser on room join
app/context/WebContext.tsx Exposes isOwner, roomUsers, promoteToAdmin, demoteFromAdmin; auto-joins room
app/components/AdminPanel.tsx New — Modal UI for managing room member roles
app/components/Topbar.tsx Added "Manage" button for owners to open AdminPanel

Test plan

  • Create a new room — verify the creator is assigned OWNER role
  • Join the room with a second account — verify a RoomUser with USER role is created
  • As owner, open the admin panel and promote the second user to ADMIN
  • Verify the promoted user now sees admin controls (skip song, chat pause toggle, song add toggle)
  • Demote the user back to USER and verify admin controls are removed
  • Verify the owner cannot be demoted or modified
  • Verify non-owner admins cannot promote/demote other users

🤖 Generated with Claude Code

- Add OWNER role to distinguish room creators from promoted admins
- Update room creation to assign OWNER role to the creator
- Update admin check to use RoomUser.role instead of only room.adminId
- Add /api/room/[roomId]/admins API for listing members and promoting/demoting
- Add /api/room/[roomId]/join API to track room membership via RoomUser
- Create AdminPanel component for the room owner to manage member roles
- Add "Manage" button in Topbar visible to room owners
- Include Prisma migration for OWNER enum value

Closes Fahad-Dezloper#27

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 12, 2026

@buildingvibes is attempting to deploy a commit to the fahad-dezloper's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple Admin Support

1 participant