-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #413 from captableinc/rbac
feat: add rbac
- Loading branch information
Showing
67 changed files
with
2,683 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- CreateEnum | ||
CREATE TYPE "Roles" AS ENUM ('ADMIN', 'CUSTOM'); | ||
|
||
-- AlterTable | ||
ALTER TABLE "Member" ADD COLUMN "customRoleId" TEXT, | ||
ADD COLUMN "role" "Roles" DEFAULT 'ADMIN'; | ||
|
||
-- CreateTable | ||
CREATE TABLE "CustomRole" ( | ||
"id" TEXT NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"companyId" TEXT NOT NULL, | ||
"permissions" JSONB[], | ||
|
||
CONSTRAINT "CustomRole_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "CustomRole_companyId_idx" ON "CustomRole"("companyId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "Member_customRoleId_idx" ON "Member"("customRoleId"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/app/(authenticated)/(dashboard)/[publicId]/settings/roles/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { PageLayout } from "@/components/dashboard/page-layout"; | ||
import { RoleCreateUpdateModalAction } from "@/components/modals/role-create-update-modal"; | ||
import { RoleTable } from "@/components/rbac/role-table"; | ||
import { Card } from "@/components/ui/card"; | ||
import { serverAccessControl } from "@/lib/rbac/access-control"; | ||
import { api } from "@/trpc/server"; | ||
|
||
export default async function RolesPage() { | ||
const { allow } = await serverAccessControl(); | ||
|
||
const data = await allow(api.rbac.listRoles.query(), ["roles", "read"]); | ||
|
||
const canCreate = allow(true, ["roles", "create"]); | ||
|
||
return ( | ||
<div className="flex flex-col gap-y-3"> | ||
<PageLayout | ||
title="Roles" | ||
description="Create and manage roles for your company." | ||
action={<RoleCreateUpdateModalAction disabled={!canCreate} />} | ||
/> | ||
|
||
{data ? <RoleTable roles={data.rolesList} /> : null} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.