Skip to content

fix: block server owner from leaving without transferring ownership (#178)#179

Open
yashrajpurohit7 wants to merge 1 commit into
0rigin-c0de:mainfrom
yashrajpurohit7:fix/prevent-owner-leaving-server
Open

fix: block server owner from leaving without transferring ownership (#178)#179
yashrajpurohit7 wants to merge 1 commit into
0rigin-c0de:mainfrom
yashrajpurohit7:fix/prevent-owner-leaving-server

Conversation

@yashrajpurohit7
Copy link
Copy Markdown

Fixes #178

The leave_server endpoint had no role check - server owners
could leave just like regular members, making the server
permanently ownerless.

What I changed:

Added a role check before the leave logic runs. It queries the
user's servers array to find their role for that specific server.

Three cases are now handled:

  • Regular member proceeds with normal leave as before
  • Owner with other members blocked with 403, asked to
    transfer ownership first
  • Solo owner (only member) allowed to leave, server is
    soft deleted automatically

The role and member count data was already in the DB
it just wasn't being checked anywhere in this route.

Files changed :

  • server/routes/servers.js

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 26, 2026

@yashrajpurohit7 is attempting to deploy a commit to the Sunil Kumar's projects Team on Vercel.

A member of the Team first needs to authorize it.

@0rigin-c0de
Copy link
Copy Markdown
Owner

@yashrajpurohit7 Can you please resolve merge conflicts
If you need any help let me know

@yashrajpurohit7 yashrajpurohit7 force-pushed the fix/prevent-owner-leaving-server branch from 2b64ac2 to edab6be Compare May 29, 2026 12:41
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.

[Bug]: Server owner can leave without transferring ownership - creates permanently unmanageable server

2 participants