Fix bug where games don't load if user is not logged in

main
sudoer777 2021-11-26 12:53:54 -07:00
parent 3201ffb2a9
commit bb335c7aca
2 changed files with 11 additions and 8 deletions

View File

@ -177,11 +177,14 @@ genderDropdown.onchange = listDivisions;
teamDropdown.onchange = listGames; teamDropdown.onchange = listGames;
seasonDropdown.onchange = listGames; seasonDropdown.onchange = listGames;
if(addScoreButton) {
addScoreButton.addEventListener('click', () => { addScoreButton.addEventListener('click', () => {
window.location.href = '/manage/game'; window.location.href = '/manage/game';
}); });
}
if(manageButton) {
manageButton.addEventListener('click', () => { manageButton.addEventListener('click', () => {
window.location.href = '/manage' window.location.href = '/manage'
}); });
}

View File

@ -71,7 +71,7 @@ router.get('/team', function(req, res, next) {
}) })
router.get('/games', function(req, res, next) { router.get('/games', function(req, res, next) {
const userID = req.user[0]; const userID = req.user ? req.user[0] : null;
if(req.query.user) games.retrieveByUser(userID).then(data => res.json(data)); if(req.query.user) games.retrieveByUser(userID).then(data => res.json(data));
else games.retrieve(req.query.team, req.query.division, req.query.season).then(data => res.json(data)); else games.retrieve(req.query.team, req.query.division, req.query.season).then(data => res.json(data));
}) })