File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed
Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -578,14 +578,6 @@ export const cardRouter = createTRPCRouter({
578578 > ( ) ,
579579 )
580580 . query ( async ( { ctx, input } ) => {
581- const userId = ctx . user ?. id ;
582-
583- if ( ! userId )
584- throw new TRPCError ( {
585- message : `User not authenticated` ,
586- code : "UNAUTHORIZED" ,
587- } ) ;
588-
589581 const card = await cardRepo . getWorkspaceAndCardIdByCardPublicId (
590582 ctx . db ,
591583 input . cardPublicId ,
@@ -597,7 +589,17 @@ export const cardRouter = createTRPCRouter({
597589 code : "NOT_FOUND" ,
598590 } ) ;
599591
600- await assertUserInWorkspace ( ctx . db , userId , card . workspaceId ) ;
592+ if ( card . workspaceVisibility === "private" ) {
593+ const userId = ctx . user ?. id ;
594+
595+ if ( ! userId )
596+ throw new TRPCError ( {
597+ message : `User not authenticated` ,
598+ code : "UNAUTHORIZED" ,
599+ } ) ;
600+
601+ await assertUserInWorkspace ( ctx . db , userId , card . workspaceId ) ;
602+ }
601603
602604 const result = await cardRepo . getWithListAndMembersByPublicId (
603605 ctx . db ,
Original file line number Diff line number Diff line change @@ -731,6 +731,7 @@ export const getWorkspaceAndCardIdByCardPublicId = async (
731731 board : {
732732 columns : {
733733 workspaceId : true ,
734+ visibility : true ,
734735 } ,
735736 } ,
736737 } ,
@@ -742,6 +743,7 @@ export const getWorkspaceAndCardIdByCardPublicId = async (
742743 ? {
743744 id : result . id ,
744745 workspaceId : result . list . board . workspaceId ,
746+ workspaceVisibility : result . list . board . visibility ,
745747 }
746748 : null ;
747749} ;
You can’t perform that action at this time.
0 commit comments