Add proper redirects for PUBLIC_SUBMIT_PAGE variable
parent
06a7970fe7
commit
7f6fd92abc
|
@ -12,13 +12,29 @@ var accounts = require('../database/accounts/accounts');
|
||||||
|
|
||||||
var checkLoginStatus = require('./checkLoginStatus');
|
var checkLoginStatus = require('./checkLoginStatus');
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV !== 'production' || process.env.NODE_ENV !== 'testing') {
|
||||||
|
require('dotenv').config();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
router.get('/' ,checkLoginStatus.user, function(req, res, next) {
|
router.get('/' ,checkLoginStatus.user, function(req, res, next) {
|
||||||
if(req.user[2]) res.render('manage', { title: 'Management Panel', userLoggedIn: !!req.user });
|
if(req.user[2]) res.render('manage', { title: 'Management Panel', userLoggedIn: !!req.user });
|
||||||
else res.render('manage/manage-nonadmin', { title: "My Games", userLoggedIn: !!req.user });
|
else res.render('manage/manage-nonadmin', { title: "My Games", userLoggedIn: !!req.user });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/game', checkLoginStatus.user, function(req, res, next) {
|
router.get('/game', function(req, res, next) {
|
||||||
|
if(!(process.env.PUBLIC_SUBMIT_PAGE && process.env.PUBLIC_SUBMIT_PAGE.toLowerCase() == 'true')) {
|
||||||
|
if (req.user) {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
res.redirect('/auth/login');
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function(req, res, next) {
|
||||||
let title = req.query.game ? 'Edit Game' : 'Submit Score'
|
let title = req.query.game ? 'Edit Game' : 'Submit Score'
|
||||||
|
|
||||||
res.render('manage/addgame', { title, userLoggedIn: !!req.user, message: req.flash('error') });
|
res.render('manage/addgame', { title, userLoggedIn: !!req.user, message: req.flash('error') });
|
||||||
|
|
Reference in New Issue