@@ -50,16 +50,16 @@ exports.login = async function(req, res) {
5050 let dice = Factory . create ( req . body . site ) ;
5151 let ret = await dice . login ( req . body . username , req . body . password , req . body . twofa , req . body . apikey , req ) ;
5252 if ( ret != true ) {
53- res . render ( 'login' , { message :ret , site :req . params . site , skin :req . session . skin } ) ;
53+ res . render ( 'login' , { title : 'My Dice Bot' , message :ret , site :req . params . site , skin :req . session . skin } ) ;
5454 } else {
55- res . redirect ( req . protocol + "://" + req . headers . host + '/' + req . body . site + ' /info' ) ;
55+ res . redirect ( req . protocol + "://" + req . headers . host + "/" + req . body . site + " /info" ) ;
5656 }
5757 } else {
58- res . render ( 'login' , { site :req . params . site , skin :req . session . skin } ) ;
58+ res . render ( 'login' , { title : 'My Dice Bot' , site :req . params . site , skin :req . session . skin } ) ;
5959 }
6060 } catch ( err ) {
6161 console . log ( err ) ;
62- res . render ( 'login' , { message :err . toString ( ) , site :req . params . site , skin :req . session . skin } ) ;
62+ res . render ( 'login' , { title : 'My Dice Bot' , message :err . toString ( ) , site :req . params . site , skin :req . session . skin } ) ;
6363 }
6464} ;
6565
@@ -75,6 +75,7 @@ exports.info = async function(req, res) {
7575 ret . authSteem = encodeURIComponent ( config . mydice . oauth . steem . url ) ;
7676 ret . skin = req . session . skin ;
7777 ret . codeSkin = 'default' ;
78+ ret . title = 'My Dice Bot' ;
7879 ret . url = config . mydice . url ;
7980 if ( req . session . skin == 'Contrast' ) {
8081 ret . codeSkin = 'night' ;
@@ -128,6 +129,9 @@ exports.keecheck = async function(req, res) {
128129 //filePath = path.resolve('/tmp/keepass/'+keepassfile+'.kdbx');
129130 filePath = path . resolve ( path . join ( __dirname , '../../keepass/' + keepassfile + '.kdbx' ) ) ;
130131 }
132+ if ( process . env . electron ) {
133+ filePath = path . resolve ( path . join ( config . mydice . path , '/keepass/' + keepassfile + '.kdbx' ) ) ;
134+ }
131135 if ( fs . existsSync ( filePath ) ) {
132136 return res . status ( 200 ) . json ( true ) ;
133137 } else {
@@ -146,6 +150,9 @@ exports.keeload = async function(req, res) {
146150 //filePath = path.resolve('/tmp/keepass/'+req.body.keepassfile+'.kdbx');
147151 filePath = path . resolve ( path . join ( __dirname , '../../keepass/' + req . body . keepassfile + '.kdbx' ) ) ;
148152 }
153+ if ( process . env . electron ) {
154+ filePath = path . resolve ( path . join ( config . mydice . path , '/keepass/' + req . body . keepassfile + '.kdbx' ) ) ;
155+ }
149156 let cred = new kdbxweb . Credentials ( kdbxweb . ProtectedValue . fromString ( req . body . keepassword ) ) ;
150157 let data = await fs . readFileSync ( filePath ) ;
151158 let db = await kdbxweb . Kdbx . load ( new Uint8Array ( data ) . buffer , cred ) ;
@@ -179,6 +186,9 @@ exports.keereg = async function(req, res) {
179186 //filePath = path.resolve('/tmp/keepass/'+req.body.keepassfile+'.kdbx');
180187 filePath = path . resolve ( path . join ( __dirname , '../../keepass/' + req . body . keepassfile + '.kdbx' ) ) ;
181188 }
189+ if ( process . env . electron ) {
190+ filePath = path . resolve ( path . join ( config . mydice . path , '/keepass/' + req . body . keepassfile + '.kdbx' ) ) ;
191+ }
182192 let cred = new kdbxweb . Credentials ( kdbxweb . ProtectedValue . fromString ( req . body . keepassword ) ) ;
183193 let db = kdbxweb . Kdbx . create ( cred , 'mydicebot' ) ;
184194 //let subGroup = db.createGroup(db.getDefaultGroup(), 'mydicebot');
@@ -199,6 +209,9 @@ exports.keesave = async function(req, res) {
199209 //filePath = path.resolve('/tmp/keepass/'+req.body.keepassfile+'.kdbx');
200210 filePath = path . resolve ( path . join ( __dirname , '../../keepass/' + req . query . keepassfile + '.kdbx' ) ) ;
201211 }
212+ if ( process . env . electron ) {
213+ filePath = path . resolve ( path . join ( config . mydice . path , '/keepass/' + req . query . keepassfile + '.kdbx' ) ) ;
214+ }
202215 let cred = new kdbxweb . Credentials ( kdbxweb . ProtectedValue . fromString ( req . query . keepassword ) ) ;
203216 let db = kdbxweb . Kdbx . create ( cred , 'mydicebot' ) ;
204217 for ( let k1 in req . body ) {
@@ -239,6 +252,9 @@ exports.keefiles = async function(req, res) {
239252 //filePath = path.resolve('/tmp/keepass/');
240253 filePath = path . resolve ( path . join ( __dirname , '../../keepass/' ) ) ;
241254 }
255+ if ( process . env . electron ) {
256+ filePath = path . resolve ( path . join ( config . mydice . path , '/keepass/' ) ) ;
257+ }
242258 let paths = await getFiles ( filePath , 'kdbx' ) ;
243259 return res . status ( 200 ) . json ( paths ) ;
244260 } catch ( err ) {
@@ -259,6 +275,9 @@ exports.save = async function(req, res) {
259275 //filePath = path.resolve('/tmp/script/lua/'+fileName);
260276 filePath = path . resolve ( path . join ( __dirname , '../../script/' + ext + '/' + fileName ) ) ;
261277 }
278+ if ( process . env . electron ) {
279+ filePath = path . resolve ( path . join ( config . mydice . path , '/script/' + ext + '/' + fileName ) ) ;
280+ }
262281 let str = await writeFile ( filePath , content ) ;
263282 return res . status ( 200 ) . json ( str ) ;
264283 } catch ( err ) {
@@ -277,6 +296,9 @@ exports.file = async function(req, res) {
277296 //filePath = path.resolve('/tmp/script/lua/'+req.query.file);
278297 filePath = path . resolve ( path . join ( __dirname , '../../script/' + ext + '/' + req . query . file ) ) ;
279298 }
299+ if ( process . env . electron ) {
300+ filePath = path . resolve ( path . join ( config . mydice . path , '/script/' + ext + '/' + req . query . file ) ) ;
301+ }
280302 let content = await readFile ( filePath ) ;
281303 return res . status ( 200 ) . json ( content ) ;
282304 } catch ( err ) {
@@ -294,6 +316,9 @@ exports.script = async function(req, res) {
294316 //filePath = path.resolve('/tmp/script/lua/');
295317 filePath = path . resolve ( path . join ( __dirname , '../../script/' + ext + '/' ) ) ;
296318 }
319+ if ( process . env . electron ) {
320+ filePath = path . resolve ( path . join ( config . mydice . path , '/script/' + ext + '/' ) ) ;
321+ }
297322 let paths = await getFiles ( filePath , ext ) ;
298323 return res . status ( 200 ) . json ( paths ) ;
299324 } catch ( err ) {
@@ -312,6 +337,9 @@ exports.del = async function(req, res) {
312337 //filePath = path.resolve('/tmp/script/lua/'+req.query.file);
313338 filePath = path . resolve ( path . join ( __dirname , '../../script/' + ext + '/' + req . query . file ) ) ;
314339 }
340+ if ( process . env . electron ) {
341+ filePath = path . resolve ( path . join ( config . mydice . path , '/script/' + ext + '/' + req . query . file ) ) ;
342+ }
315343 fs . unlinkSync ( filePath ) ;
316344 return res . status ( 200 ) . json ( 'ok' ) ;
317345 } catch ( err ) {
@@ -332,6 +360,9 @@ exports.upload = async function(req, res) {
332360 //filePath = path.resolve('/tmp/script/lua/'+files.upload.name);
333361 filePath = path . resolve ( path . join ( __dirname , '../../script/' + ext + '/' + files . upload . name ) ) ;
334362 }
363+ if ( process . env . electron ) {
364+ filePath = path . resolve ( path . join ( config . mydice . path , '/script/' + ext + '/' + files . upload . name ) ) ;
365+ }
335366 fs . writeFileSync ( filePath , fs . readFileSync ( files . upload . path ) ) ;
336367 return res . status ( 200 ) . json ( 'ok' ) ;
337368 } ) ;
0 commit comments