permission fix
All checks were successful
Build Images and Deploy / Update-PROD-Stack (push) Successful in 29s
All checks were successful
Build Images and Deploy / Update-PROD-Stack (push) Successful in 29s
This commit is contained in:
@@ -21,8 +21,8 @@ router.use(requireOrganizerOrAdmin);
|
|||||||
|
|
||||||
// Admin/Organizer dashboard
|
// Admin/Organizer dashboard
|
||||||
router.get('/', (req, res) => {
|
router.get('/', (req, res) => {
|
||||||
const hunts = Hunts.getByCreator(req.session.userId);
|
|
||||||
const isAdmin = !!req.session.isAdmin;
|
const isAdmin = !!req.session.isAdmin;
|
||||||
|
const hunts = isAdmin ? Hunts.getAll() : Hunts.getByCreator(req.session.userId);
|
||||||
|
|
||||||
// Only admins see the full user list and password reset
|
// Only admins see the full user list and password reset
|
||||||
const users = isAdmin ? Users.getAllUsers() : [];
|
const users = isAdmin ? Users.getAllUsers() : [];
|
||||||
@@ -178,7 +178,7 @@ router.post('/reset-password', requireAdmin, (req, res) => {
|
|||||||
const user = Users.findByUsername(username);
|
const user = Users.findByUsername(username);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
const hunts = Hunts.getByCreator(req.session.userId);
|
const hunts = Hunts.getAll();
|
||||||
const users = Users.getAllUsers();
|
const users = Users.getAllUsers();
|
||||||
req.session.flash = { type: 'danger', message: `User "${username}" not found.` };
|
req.session.flash = { type: 'danger', message: `User "${username}" not found.` };
|
||||||
return res.redirect('/admin');
|
return res.redirect('/admin');
|
||||||
@@ -188,7 +188,7 @@ router.post('/reset-password', requireAdmin, (req, res) => {
|
|||||||
const baseUrl = process.env.BASE_URL || `http://localhost:${process.env.PORT || 3000}`;
|
const baseUrl = process.env.BASE_URL || `http://localhost:${process.env.PORT || 3000}`;
|
||||||
const resetUrl = `${baseUrl}/auth/reset/${token}`;
|
const resetUrl = `${baseUrl}/auth/reset/${token}`;
|
||||||
|
|
||||||
const hunts = Hunts.getByCreator(req.session.userId);
|
const hunts = Hunts.getAll();
|
||||||
const users = Users.getAllUsers();
|
const users = Users.getAllUsers();
|
||||||
res.render('admin/dashboard', {
|
res.render('admin/dashboard', {
|
||||||
title: 'Admin Dashboard',
|
title: 'Admin Dashboard',
|
||||||
|
|||||||
Reference in New Issue
Block a user