@@ -50,16 +50,16 @@ exports.login = async function(req, res) {
50
50
let dice = Factory . create ( req . body . site ) ;
51
51
let ret = await dice . login ( req . body . username , req . body . password , req . body . twofa , req . body . apikey , req ) ;
52
52
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 } ) ;
54
54
} 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" ) ;
56
56
}
57
57
} 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 } ) ;
59
59
}
60
60
} catch ( err ) {
61
61
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 } ) ;
63
63
}
64
64
} ;
65
65
@@ -75,6 +75,7 @@ exports.info = async function(req, res) {
75
75
ret . authSteem = encodeURIComponent ( config . mydice . oauth . steem . url ) ;
76
76
ret . skin = req . session . skin ;
77
77
ret . codeSkin = 'default' ;
78
+ ret . title = 'My Dice Bot' ;
78
79
ret . url = config . mydice . url ;
79
80
if ( req . session . skin == 'Contrast' ) {
80
81
ret . codeSkin = 'night' ;
@@ -128,6 +129,9 @@ exports.keecheck = async function(req, res) {
128
129
//filePath = path.resolve('/tmp/keepass/'+keepassfile+'.kdbx');
129
130
filePath = path . resolve ( path . join ( __dirname , '../../keepass/' + keepassfile + '.kdbx' ) ) ;
130
131
}
132
+ if ( process . env . electron ) {
133
+ filePath = path . resolve ( path . join ( config . mydice . path , '/keepass/' + keepassfile + '.kdbx' ) ) ;
134
+ }
131
135
if ( fs . existsSync ( filePath ) ) {
132
136
return res . status ( 200 ) . json ( true ) ;
133
137
} else {
@@ -146,6 +150,9 @@ exports.keeload = async function(req, res) {
146
150
//filePath = path.resolve('/tmp/keepass/'+req.body.keepassfile+'.kdbx');
147
151
filePath = path . resolve ( path . join ( __dirname , '../../keepass/' + req . body . keepassfile + '.kdbx' ) ) ;
148
152
}
153
+ if ( process . env . electron ) {
154
+ filePath = path . resolve ( path . join ( config . mydice . path , '/keepass/' + req . body . keepassfile + '.kdbx' ) ) ;
155
+ }
149
156
let cred = new kdbxweb . Credentials ( kdbxweb . ProtectedValue . fromString ( req . body . keepassword ) ) ;
150
157
let data = await fs . readFileSync ( filePath ) ;
151
158
let db = await kdbxweb . Kdbx . load ( new Uint8Array ( data ) . buffer , cred ) ;
@@ -179,6 +186,9 @@ exports.keereg = async function(req, res) {
179
186
//filePath = path.resolve('/tmp/keepass/'+req.body.keepassfile+'.kdbx');
180
187
filePath = path . resolve ( path . join ( __dirname , '../../keepass/' + req . body . keepassfile + '.kdbx' ) ) ;
181
188
}
189
+ if ( process . env . electron ) {
190
+ filePath = path . resolve ( path . join ( config . mydice . path , '/keepass/' + req . body . keepassfile + '.kdbx' ) ) ;
191
+ }
182
192
let cred = new kdbxweb . Credentials ( kdbxweb . ProtectedValue . fromString ( req . body . keepassword ) ) ;
183
193
let db = kdbxweb . Kdbx . create ( cred , 'mydicebot' ) ;
184
194
//let subGroup = db.createGroup(db.getDefaultGroup(), 'mydicebot');
@@ -199,6 +209,9 @@ exports.keesave = async function(req, res) {
199
209
//filePath = path.resolve('/tmp/keepass/'+req.body.keepassfile+'.kdbx');
200
210
filePath = path . resolve ( path . join ( __dirname , '../../keepass/' + req . query . keepassfile + '.kdbx' ) ) ;
201
211
}
212
+ if ( process . env . electron ) {
213
+ filePath = path . resolve ( path . join ( config . mydice . path , '/keepass/' + req . query . keepassfile + '.kdbx' ) ) ;
214
+ }
202
215
let cred = new kdbxweb . Credentials ( kdbxweb . ProtectedValue . fromString ( req . query . keepassword ) ) ;
203
216
let db = kdbxweb . Kdbx . create ( cred , 'mydicebot' ) ;
204
217
for ( let k1 in req . body ) {
@@ -239,6 +252,9 @@ exports.keefiles = async function(req, res) {
239
252
//filePath = path.resolve('/tmp/keepass/');
240
253
filePath = path . resolve ( path . join ( __dirname , '../../keepass/' ) ) ;
241
254
}
255
+ if ( process . env . electron ) {
256
+ filePath = path . resolve ( path . join ( config . mydice . path , '/keepass/' ) ) ;
257
+ }
242
258
let paths = await getFiles ( filePath , 'kdbx' ) ;
243
259
return res . status ( 200 ) . json ( paths ) ;
244
260
} catch ( err ) {
@@ -259,6 +275,9 @@ exports.save = async function(req, res) {
259
275
//filePath = path.resolve('/tmp/script/lua/'+fileName);
260
276
filePath = path . resolve ( path . join ( __dirname , '../../script/' + ext + '/' + fileName ) ) ;
261
277
}
278
+ if ( process . env . electron ) {
279
+ filePath = path . resolve ( path . join ( config . mydice . path , '/script/' + ext + '/' + fileName ) ) ;
280
+ }
262
281
let str = await writeFile ( filePath , content ) ;
263
282
return res . status ( 200 ) . json ( str ) ;
264
283
} catch ( err ) {
@@ -277,6 +296,9 @@ exports.file = async function(req, res) {
277
296
//filePath = path.resolve('/tmp/script/lua/'+req.query.file);
278
297
filePath = path . resolve ( path . join ( __dirname , '../../script/' + ext + '/' + req . query . file ) ) ;
279
298
}
299
+ if ( process . env . electron ) {
300
+ filePath = path . resolve ( path . join ( config . mydice . path , '/script/' + ext + '/' + req . query . file ) ) ;
301
+ }
280
302
let content = await readFile ( filePath ) ;
281
303
return res . status ( 200 ) . json ( content ) ;
282
304
} catch ( err ) {
@@ -294,6 +316,9 @@ exports.script = async function(req, res) {
294
316
//filePath = path.resolve('/tmp/script/lua/');
295
317
filePath = path . resolve ( path . join ( __dirname , '../../script/' + ext + '/' ) ) ;
296
318
}
319
+ if ( process . env . electron ) {
320
+ filePath = path . resolve ( path . join ( config . mydice . path , '/script/' + ext + '/' ) ) ;
321
+ }
297
322
let paths = await getFiles ( filePath , ext ) ;
298
323
return res . status ( 200 ) . json ( paths ) ;
299
324
} catch ( err ) {
@@ -312,6 +337,9 @@ exports.del = async function(req, res) {
312
337
//filePath = path.resolve('/tmp/script/lua/'+req.query.file);
313
338
filePath = path . resolve ( path . join ( __dirname , '../../script/' + ext + '/' + req . query . file ) ) ;
314
339
}
340
+ if ( process . env . electron ) {
341
+ filePath = path . resolve ( path . join ( config . mydice . path , '/script/' + ext + '/' + req . query . file ) ) ;
342
+ }
315
343
fs . unlinkSync ( filePath ) ;
316
344
return res . status ( 200 ) . json ( 'ok' ) ;
317
345
} catch ( err ) {
@@ -332,6 +360,9 @@ exports.upload = async function(req, res) {
332
360
//filePath = path.resolve('/tmp/script/lua/'+files.upload.name);
333
361
filePath = path . resolve ( path . join ( __dirname , '../../script/' + ext + '/' + files . upload . name ) ) ;
334
362
}
363
+ if ( process . env . electron ) {
364
+ filePath = path . resolve ( path . join ( config . mydice . path , '/script/' + ext + '/' + files . upload . name ) ) ;
365
+ }
335
366
fs . writeFileSync ( filePath , fs . readFileSync ( files . upload . path ) ) ;
336
367
return res . status ( 200 ) . json ( 'ok' ) ;
337
368
} ) ;
0 commit comments