Skip to content

feat(roles): ✨ add delete role functionality with confirmation dialog#725

Open
aXenDeveloper wants to merge 1 commit into
canaryfrom
feat/role_delete
Open

feat(roles): ✨ add delete role functionality with confirmation dialog#725
aXenDeveloper wants to merge 1 commit into
canaryfrom
feat/role_delete

Conversation

@aXenDeveloper

Copy link
Copy Markdown
Owner

Improving Documentation

Description

What?

Why?

@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vitnode-docs Ready Ready Preview, Comment Jul 24, 2026 9:53pm

@github-actions github-actions Bot added the 💡 Feature A new feature label Jul 24, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 784ad813ec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +11 to +12
export const deleteRoleAdminRoute = buildRoute({
pluginId: CONFIG_PLUGIN.pluginId,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Require can_manage before deleting roles

Any authenticated admin can currently invoke this destructive endpoint, including restricted admins who lack the declared @vitnode/core:roles:can_manage permission, because the route omits adminStaffPermission. The global admin middleware only validates the admin session, so add the roles can_manage authorization guard before allowing reassignment and deletion.

Useful? React with 👍 / 👎.

await tx.delete(core_roles).where(eq(core_roles.id, roleId));
});

await c.get("events").emit("role.deleted", { roleId });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Document the newly emitted role.deleted event

This turns role.deleted into a real built-in event, but apps/docs/content/docs/dev/events/built-in-events.mdx still describes it as “Declared only” with no deletion flow. Update that event documentation so plugin authors can reliably discover and use the new behavior.

AGENTS.md reference: AGENTS.md:L46-L47

Useful? React with 👍 / 👎.

return;
}

toast.success(t("success"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add a description to the deletion toast

After a successful deletion, this toast supplies only a title, so the new flow does not meet the repository requirement that create/edit/delete notifications include a description. Pass a localized description to toast.success while retaining the existing table revalidation.

AGENTS.md reference: AGENTS.md:L11-L11

Useful? React with 👍 / 👎.

import { core_roles } from "@/database/roles";
import { core_users, core_users_secondary_roles } from "@/database/users";

export const deleteRoleAdminRoute = buildRoute({

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add Vitest coverage for role deletion

The commit adds no tests for this destructive route despite the package having Vitest configured. Cover at least protected-role rejection, missing or invalid reassignment targets, user reassignment with duplicate secondary roles, permission enforcement, and successful deletion so these data-integrity and authorization branches cannot regress unnoticed.

AGENTS.md reference: AGENTS.md:L87-L90

Useful? React with 👍 / 👎.

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

Labels

💡 Feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant