fix: restrict backup restore to admins#601
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f8a55ee79f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const backupId = Number(req.params.id); | ||
|
|
||
| if (!req.user.is_admin && req.user.id !== userId) return res.status(403).json({ error: 'Access denied' }); | ||
| if (!req.user.is_admin) return res.status(403).json({ error: 'Access denied' }); |
There was a problem hiding this comment.
Keep non-admin backup flow usable after restore permission change
This change makes POST /api/users/:userId/backups/:id/restore return 403 for every non-admin request, but non-admin users are still routed through the backup UI flow (see loadUsers() handling of non-admins and restore button/API call in public/app.js), so they can create backups yet always hit an access-denied error when trying to restore them. That is a user-facing regression introduced by this authorization change; either the non-admin restore action needs to be removed/disabled in the UI (and related messaging updated) or the server-side policy needs a compatible fallback.
Useful? React with 👍 / 👎.
Motivation
user_channelsrows that re-granted previously revoked streaming access.Description
restoreBackupadmin-only by rejecting requests whenreq.user.is_adminis false, leaving listing and creation endpoints unchanged.docs/API_REFERENCE.mdto document that the restore endpoint is admin-only.tests/controllers/backupController.test.jsthat asserts non-admin restores are denied and admin restores are allowed.Testing
npm run lintwhich completed (repository contains pre-existing warnings but lint finished successfully).npm exec vitest run tests/controllers/backupController.test.jsand the new tests passed (2 tests).Codex Task