一键导入
role-auth-extension
Use when extending user roles or securing pages behind custom roles (e.g. adding VENDOR, MANAGER, etc.).
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when extending user roles or securing pages behind custom roles (e.g. adding VENDOR, MANAGER, etc.).
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | role-auth-extension |
| description | Use when extending user roles or securing pages behind custom roles (e.g. adding VENDOR, MANAGER, etc.). |
Follow these steps to add new roles (e.g., VENDOR, MANAGER, DELIVERY) and secure pages or endpoints accordingly:
Update schema.prisma:
prisma/schema.prisma.enum Role to include your new role:
enum Role {
USER
ADMIN
VENDOR // New role
}
npx prisma migrate dev --name add_role_vendor and npx prisma generate.Update Type Definitions:
src/types/next-auth.d.ts and add the new role string to the typescript Union type if it is strictly typed.Secure API Route Handlers:
const session = await auth();
if (session?.user?.role !== "VENDOR") {
return Response.json({ error: "Access denied" }, { status: 403 });
}
createApiRoute:
handler: async (req, { session }) => {
if (session.user.role !== "VENDOR") {
return Response.json({ error: "Forbidden" }, { status: 403 });
}
// ...
}
Secure Frontend Pages:
src/middleware.ts to block unauthorized navigation./dashboard/vendor/*) and checking token.role.Use when adding a brand-new CRUD resource beyond the core entity (e.g. a second model the PS requires).
Use when building or restyling any page or component.
Use when constructing forms, inputs, submit behaviors, validation displays, and feedback toast alerts.
Use when creating new Next.js route handlers using the custom helper wrapper.
Use whenever the Prisma schema changes and a migration is needed.
Use when integrating third-party APIs (e.g. SMTP emails, SMS notification gateways, payment checkout gates, or OCR parsers).