Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ You can also pre-create devices and assign configs yourself if needed.
3.) Run `npm run start`

## Notes
If you use HAProxy, make sure to set `option forwardfor` in your haproxy.cfg if you are not passing the x-forward-for header so the correct IP addresses are saved.
- If you use HAProxy, make sure to set `option forwardfor` in your haproxy.cfg if you are not passing the x-forward-for header so the correct IP addresses are saved.
- `Backend Url` and `Data Endpoints` do not need to have the `/raw` or `/controler` endpoints added to configs.

## PM2 (recommended)
Once everything is setup and running appropriately, you can add this to PM2 ecosystem.config.js file so it is automatically started:
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const timezones = require('../static/data/timezones.json');
// TODO: Secure /api/config endpoint with token
// TODO: Center align data in table columns
// TODO: Change require to import
// TODO: Fix logs on mobile

const providers = [
{ name: 'GoCheats' },
Expand Down Expand Up @@ -115,7 +116,7 @@ app.use('/api', apiRoutes);

// Login middleware
app.use(function(req, res, next) {
if (req.path === '/api/login' || req.path === '/login' || req.path.includes('/api/config')) {
if (req.path === '/api/login' || req.path === '/login' || req.path === '/api/config') {
return next();
}
if (req.session.loggedin) {
Expand Down
15 changes: 15 additions & 0 deletions src/routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ const Device = require('../models/device.js');
const Log = require('../models/log.js');
const ScheduleManager = require('../models/schedule-manager.js');

router.use(function(req, res, next) {
if (req.path === '/api/login' || req.path === '/login' ||
req.path === '/config' || req.path === '/log/new') {
return next();
}
if (req.session.loggedin) {
next();
return;
}
//if (defaultData.csrf !== req.csrfToken()) {
// console.log("TOKEN GOOD");
// //return next();
//}
res.redirect('/login');
});

// Authentication API Route
router.post('/login', async function(req, res) {
Expand Down
1 change: 0 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ function getDateTime(timestamp) {
function buildConfig(provider, backendUrl, dataEndpoints, token, heartbeatMaxTime, minDelayLogout,
accountManager, deployEggs, nearbyTracker, autoLogin) {
var obj = {};
console.log("Provider:", provider);
switch (provider) {
case 'GoCheats':
obj = {
Expand Down