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