Skip to content

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

Open
yashrajpurohit7 wants to merge 1 commit into
chthonn: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
chthonn: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

@yashrajpurohit7 yashrajpurohit7 requested a review from chthonn as a code owner May 26, 2026 08:57
@vercel

vercel Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

@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.

@chthonn

chthonn commented May 29, 2026

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
@Karanjot786

Copy link
Copy Markdown

Hey @yashrajpurohit7! Saw your work on GSSoC 2026.

We are building TermUI, a TypeScript terminal UI framework with React-style hooks and JSX, rendered entirely in the terminal.

We have 67 unassigned GSSoC issues open. 19 are marked good first issue. Your TypeScript background transfers directly.

Karanjot, TermUI maintainer

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

3 participants