Update Dockerfile and server.js to handle setup and user configurations
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -12,9 +12,9 @@ RUN [ ! -f cdn-files ] && touch cdn-files || true
|
||||
|
||||
RUN [ ! -f report ] && touch report || true
|
||||
|
||||
RUN [ ! -f user.json ] && touch user.json || true
|
||||
RUN [ ! -f setup.json ] && echo '{}' > setup.json || true
|
||||
|
||||
RUN [ ! -f file_info.json ] && touch file_info.json || true
|
||||
RUN [ ! -f user.json ] && echo '{}' > user.json || true
|
||||
|
||||
EXPOSE 5053
|
||||
|
||||
|
||||
17
server.js
17
server.js
@@ -13,6 +13,13 @@ const fs = require('fs');
|
||||
const SystemReport = require('./models/reportManager.js');
|
||||
|
||||
let setup = {};
|
||||
try {
|
||||
if (fs.existsSync('setup.json')) {
|
||||
setup = JSON.parse(fs.readFileSync('setup.json', 'utf8'));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error reading setup.json:', err);
|
||||
}
|
||||
try {
|
||||
setup = JSON.parse(fs.readFileSync('setup.json', 'utf8'));
|
||||
} catch (err) {
|
||||
@@ -27,6 +34,16 @@ if (setup.ldap !== undefined) {
|
||||
require('./models/Passport-ActiveDirectory.js');
|
||||
}
|
||||
|
||||
let user = {};
|
||||
try {
|
||||
if (fs.existsSync('user.json')) {
|
||||
const data = fs.readFileSync('user.json', 'utf8');
|
||||
user = data ? JSON.parse(data) : {};
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error reading user.json:', err);
|
||||
}
|
||||
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
app.get(['/user.json', '/file_info.json', '/setup.json'], (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user