Add board share management UI

This commit is contained in:
Mike Cao committed 2026-03-08 22:24:24 -07:00
1 parent b429e7b24d
commit c4226bc63d
30 files changed
+565 -56

No files matched your search

+29 -1
View File
@@ -3,13 +3,25 @@ import { PERMISSIONS } from '@/lib/constants';
import type { Auth } from '@/lib/types';
import { getBoard, getTeamUser } from '@/queries/prisma';
export async function canViewBoard({ user }: Auth, boardId: string) {
export async function canViewBoard({ user, shareToken }: Auth, boardId: string) {
if (user?.isAdmin) {
return true;
}
if (shareToken?.boardId === boardId) {
return true;
}
if (!user) {
return false;
}
const board = await getBoard(boardId);
if (!board) {
return false;
}
if (board.userId) {
return user.id === board.userId;
}
@@ -24,12 +36,20 @@ export async function canViewBoard({ user }: Auth, boardId: string) {
}
export async function canUpdateBoard({ user }: Auth, boardId: string) {
if (!user) {
return false;
}
if (user.isAdmin) {
return true;
}
const board = await getBoard(boardId);
if (!board) {
return false;
}
if (board.userId) {
return user.id === board.userId;
}
@@ -44,12 +64,20 @@ export async function canUpdateBoard({ user }: Auth, boardId: string) {
}
export async function canDeleteBoard({ user }: Auth, boardId: string) {
if (!user) {
return false;
}
if (user.isAdmin) {
return true;
}
const board = await getBoard(boardId);
if (!board) {
return false;
}
if (board.userId) {
return user.id === board.userId;
}
+12
View File
@@ -15,6 +15,10 @@ export async function canViewEntity({ user }: Auth, entityId: string) {
const entity = await getEntity(entityId);
if (!entity) {
return false;
}
if (entity.userId) {
return user.id === entity.userId;
}
@@ -39,6 +43,10 @@ export async function canUpdateEntity({ user }: Auth, entityId: string) {
const entity = await getEntity(entityId);
if (!entity) {
return false;
}
if (entity.userId) {
return user.id === entity.userId;
}
@@ -63,6 +71,10 @@ export async function canDeleteEntity({ user }: Auth, entityId: string) {
const entity = await getEntity(entityId);
if (!entity) {
return false;
}
if (entity.userId) {
return user.id === entity.userId;
}
+1 -1
View File
@@ -9,7 +9,7 @@ export async function canViewWebsite({ user, shareToken }: Auth, websiteId: stri
return true;
}
if (shareToken?.websiteId === websiteId) {
if (shareToken?.websiteId === websiteId || shareToken?.websiteIds?.includes(websiteId)) {
return true;
}