diff --git a/backend/src/middleware/ownership.js b/backend/src/middleware/ownership.js index cb6914d5..9b6b2018 100644 --- a/backend/src/middleware/ownership.js +++ b/backend/src/middleware/ownership.js @@ -1,4 +1,5 @@ const { db } = require('../database/db'); +const logger = require('../utils/logger'); /** * Middleware to enforce event ownership for non-super_admin users. @@ -27,7 +28,10 @@ function requireEventOwnership(req, res, next) { } next(); }) - .catch((_err) => { + .catch((err) => { + logger.error('Event ownership check failed', { + eventId, adminId: req.admin.id, error: err.message, stack: err.stack, + }); res.status(500).json({ error: 'Failed to verify ownership' }); }); } @@ -152,7 +156,12 @@ function requireProjectOwnership(req, res, next) { if (!row) return res.status(404).json({ error: 'Project not found' }); next(); }) - .catch(() => res.status(500).json({ error: 'Failed to verify project ownership' })); + .catch((err) => { + logger.error('Project ownership check failed', { + projectId, adminId: req.admin?.id, error: err.message, stack: err.stack, + }); + res.status(500).json({ error: 'Failed to verify project ownership' }); + }); } module.exports = { diff --git a/frontend/src/contexts/AdminAuthContext.tsx b/frontend/src/contexts/AdminAuthContext.tsx index 6b943397..20e13f5b 100644 --- a/frontend/src/contexts/AdminAuthContext.tsx +++ b/frontend/src/contexts/AdminAuthContext.tsx @@ -12,7 +12,6 @@ interface AdminAuthContextType { isLoading: boolean; error: string | null; mustChangePassword: boolean; - updatePasswordChanged: () => void; updateUserProfile: (updates: Partial) => void; } @@ -98,20 +97,6 @@ export const AdminAuthProvider: React.FC = ({ children } setMustChangePassword(false); }; - const updatePasswordChanged = () => { - setMustChangePassword(false); - if (user) { - setUser({ - ...user, - mustChangePassword: false - }); - sessionStorage.setItem('admin_user', JSON.stringify({ - ...user, - mustChangePassword: false - })); - } - }; - const updateUserProfile = (updates: Partial) => { setUser((prev) => { if (!prev) { @@ -133,7 +118,6 @@ export const AdminAuthProvider: React.FC = ({ children } isLoading, error, mustChangePassword, - updatePasswordChanged, updateUserProfile, }} >