File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -588,6 +588,12 @@ const getRemixerPageTree = async (
588588) => {
589589 try {
590590 const { subdomain, path, flatten } = req . body ;
591+
592+ const ctx = await ProjectContext . load ( req . params . id ) ;
593+ if ( ! ctx . canMember ( req . user ) ) {
594+ return returnProjectError ( res , new ProjectError ( "unauthorized" ) ) ;
595+ }
596+
591597 const bookService = new BookService ( {
592598 bookID : `${ subdomain } -${ path } ` ,
593599 } ) ;
@@ -597,6 +603,10 @@ const getRemixerPageTree = async (
597603 response : tree ,
598604 } ) ;
599605 } catch ( error ) {
606+ if ( error instanceof ProjectError ) {
607+ return returnProjectError ( res , error ) ;
608+ }
609+
600610 debug ( "[remixer] getRemixerPageTree unexpected error:" , error ) ;
601611 return conductor500Err ( res ) ;
602612 }
Original file line number Diff line number Diff line change @@ -267,10 +267,16 @@ export default class BookService {
267267 method : "GET" ,
268268 } ,
269269 } ) ;
270+
270271 if ( ! res . ok ) {
271272 throw new Error ( `Error fetching tree: ${ res . statusText } ` ) ;
272273 }
274+
273275 const rawTree = ( await res . json ( ) ) as GetPageSubPagesResponse ;
276+ if ( ! rawTree ?. page ) {
277+ throw new Error ( "No page data found in tree response" ) ;
278+ }
279+
274280 const structured = this . _buildHierarchy ( rawTree ?. page ) ;
275281
276282 if ( flatten ) {
You can’t perform that action at this time.
0 commit comments