@@ -444,30 +444,27 @@ function config_router(app) {
444444 json_response ( res , get_account_info_payload ( user_id , account , true ) )
445445 return
446446 } ) ;
447-
448- router . get ( '/notedeck-install-instructions' , app . web_auth_manager . require_web_auth . bind ( app . web_auth_manager ) , async ( req , res ) => {
449- const pubkey = req . authorized_pubkey
450- const { account, user_id } = get_account_and_user_id ( app , pubkey )
451- if ( ! account ) {
452- simple_response ( res , 404 )
453- return
454- }
455- const account_info = get_account_info_payload ( user_id , account , true )
456- if ( account_info . active == true ) {
457- const installInstructionsPath = path . resolve ( process . env . NOTEDECK_INSTALL_MD ) ;
458- try {
459- const installInstructions = fs . readFileSync ( installInstructionsPath , { encoding : 'utf8' } ) ;
460- json_response ( res , { value : installInstructions } ) ;
461- return
462- } catch ( err ) {
463- console . log ( err ) ;
464- error ( "Failed to read file: %s" , err . toString ( ) ) ;
465- error_response ( res , 'Failed to load installation instructions' ) ;
447+
448+ if ( process . env . NO_AUTH_WALL_NOTEDECK_INSTALL == "true" ) {
449+ router . get ( '/notedeck-install-instructions' , async ( req , res ) => {
450+ provide_notedeck_instructions ( req , res )
451+ } ) ;
452+ }
453+ else {
454+ router . get ( '/notedeck-install-instructions' , app . web_auth_manager . require_web_auth . bind ( app . web_auth_manager ) , async ( req , res ) => {
455+ const pubkey = req . authorized_pubkey
456+ const { account, user_id } = get_account_and_user_id ( app , pubkey )
457+ if ( ! account ) {
458+ simple_response ( res , 401 )
466459 return
467460 }
468- }
469- return
470- } ) ;
461+ const account_info = get_account_info_payload ( user_id , account , true )
462+ if ( account_info . active == true ) {
463+ provide_notedeck_instructions ( req , res )
464+ }
465+ return
466+ } ) ;
467+ }
471468
472469 // MARK: Admin routes
473470
@@ -684,4 +681,18 @@ function get_allowed_cors_origins() {
684681 }
685682}
686683
684+ async function provide_notedeck_instructions ( req , res ) {
685+ const installInstructionsPath = path . resolve ( process . env . NOTEDECK_INSTALL_MD ) ;
686+ try {
687+ const installInstructions = fs . readFileSync ( installInstructionsPath , { encoding : 'utf8' } ) ;
688+ json_response ( res , { value : installInstructions } ) ;
689+ return
690+ } catch ( err ) {
691+ console . log ( err ) ;
692+ error ( "Failed to read file: %s" , err . toString ( ) ) ;
693+ error_response ( res , 'Failed to load installation instructions' ) ;
694+ return
695+ }
696+ }
697+
687698module . exports = { config_router }
0 commit comments