@@ -8,7 +8,7 @@ import { Database } from '../../utils/database.js';
88import { Logger } from '../../utils/logger.js' ;
99import { Common } from '../../utils/common.js' ;
1010import { WSServer } from '../../utils/webSocketServer.js' ;
11- import { Authentication , SSO } from '../../models/config.model.js' ;
11+ import { Authentication } from '../../models/config.model.js' ;
1212const options = { url : '' } ;
1313const logger = Logger ;
1414const common = Common ;
@@ -96,41 +96,33 @@ export const getFile = (req, res, next) => {
9696} ;
9797export const getApplicationSettings = ( req , res , next ) => {
9898 logger . log ( { selectedNode : req . session . selectedNode , level : 'INFO' , fileName : 'RTLConf' , msg : 'Getting RTL Configuration..' } ) ;
99- const confFile = common . appConfig . rtlConfFilePath + sep + 'RTL-Config.json' ;
100- fs . readFile ( confFile , 'utf8' , ( errRes , data ) => {
101- if ( errRes ) {
102- const errMsg = 'Get Node Config Error' ;
103- const err = common . handleError ( { statusCode : 500 , message : errMsg , error : errRes } , 'RTLConf' , errMsg , req . session . selectedNode ) ;
104- return res . status ( err . statusCode ) . json ( { message : err . error , error : err . error } ) ;
105- }
106- else {
107- const appConfData = common . removeSecureData ( JSON . parse ( data ) ) ;
108- appConfData . allowPasswordUpdate = common . appConfig . allowPasswordUpdate ;
109- appConfData . enable2FA = common . appConfig . enable2FA ;
110- appConfData . selectedNodeIndex = ( req . session . selectedNode && req . session . selectedNode . index ? req . session . selectedNode . index : common . selectedNode . index ) ;
111- common . appConfig . selectedNodeIndex = appConfData . selectedNodeIndex ;
112- const token = req . headers . authorization ? req . headers . authorization . split ( ' ' ) [ 1 ] : '' ;
113- jwt . verify ( token , common . secret_key , ( err , user ) => {
114- if ( err ) {
115- // Delete unnecessary data for initial response (without security token)
116- const selNodeIdx = appConfData . nodes . findIndex ( ( node ) => node . index === appConfData . selectedNodeIndex ) || 0 ;
117- appConfData . SSO = new SSO ( ) ;
118- appConfData . secret2FA = '' ;
119- appConfData . dbDirectoryPath = '' ;
120- appConfData . nodes [ selNodeIdx ] . authentication = new Authentication ( ) ;
121- delete appConfData . nodes [ selNodeIdx ] . settings . bitcoindConfigPath ;
122- delete appConfData . nodes [ selNodeIdx ] . settings . lnServerUrl ;
123- delete appConfData . nodes [ selNodeIdx ] . settings . swapServerUrl ;
124- delete appConfData . nodes [ selNodeIdx ] . settings . boltzServerUrl ;
125- delete appConfData . nodes [ selNodeIdx ] . settings . enableOffers ;
126- delete appConfData . nodes [ selNodeIdx ] . settings . enablePeerswap ;
127- delete appConfData . nodes [ selNodeIdx ] . settings . channelBackupPath ;
128- appConfData . nodes = [ appConfData . nodes [ selNodeIdx ] ] ;
129- }
130- logger . log ( { selectedNode : req . session . selectedNode , level : 'INFO' , fileName : 'RTLConf' , msg : 'RTL Configuration Received' , data : appConfData } ) ;
131- res . status ( 200 ) . json ( appConfData ) ;
132- } ) ;
99+ const appConfData = common . removeSecureData ( JSON . parse ( JSON . stringify ( common . appConfig ) ) ) ;
100+ appConfData . allowPasswordUpdate = common . appConfig . allowPasswordUpdate ;
101+ appConfData . enable2FA = common . appConfig . enable2FA ;
102+ appConfData . selectedNodeIndex = ( req . session . selectedNode && req . session . selectedNode . index ? req . session . selectedNode . index : common . selectedNode . index ) ;
103+ common . appConfig . selectedNodeIndex = appConfData . selectedNodeIndex ;
104+ const token = req . headers . authorization ? req . headers . authorization . split ( ' ' ) [ 1 ] : '' ;
105+ jwt . verify ( token , common . secret_key , ( err , user ) => {
106+ if ( err ) {
107+ // Delete unnecessary data for initial response (without security token)
108+ const selNodeIdx = appConfData . nodes . findIndex ( ( node ) => node . index === appConfData . selectedNodeIndex ) || 0 ;
109+ delete appConfData . SSO . rtlCookiePath ;
110+ delete appConfData . SSO . cookieValue ;
111+ delete appConfData . SSO . logoutRedirectLink ;
112+ appConfData . secret2FA = '' ;
113+ appConfData . dbDirectoryPath = '' ;
114+ appConfData . nodes [ selNodeIdx ] . authentication = new Authentication ( ) ;
115+ delete appConfData . nodes [ selNodeIdx ] . settings . bitcoindConfigPath ;
116+ delete appConfData . nodes [ selNodeIdx ] . settings . lnServerUrl ;
117+ delete appConfData . nodes [ selNodeIdx ] . settings . swapServerUrl ;
118+ delete appConfData . nodes [ selNodeIdx ] . settings . boltzServerUrl ;
119+ delete appConfData . nodes [ selNodeIdx ] . settings . enableOffers ;
120+ delete appConfData . nodes [ selNodeIdx ] . settings . enablePeerswap ;
121+ delete appConfData . nodes [ selNodeIdx ] . settings . channelBackupPath ;
122+ appConfData . nodes = [ appConfData . nodes [ selNodeIdx ] ] ;
133123 }
124+ logger . log ( { selectedNode : req . session . selectedNode , level : 'INFO' , fileName : 'RTLConf' , msg : 'RTL Configuration Received' , data : appConfData } ) ;
125+ res . status ( 200 ) . json ( appConfData ) ;
134126 } ) ;
135127} ;
136128export const updateSelectedNode = ( req , res , next ) => {
0 commit comments