From f14de28daa3a08fe00c55e873278513f571406a4 Mon Sep 17 00:00:00 2001 From: Ryan Kegel Date: Sat, 31 Jan 2026 19:48:51 -0500 Subject: [PATCH] feat: Implement user validation and ownership checks for image, reward, and task APIs - Added `get_validated_user_id` utility function to validate user authentication across multiple APIs. - Updated image upload, request, and listing endpoints to ensure user ownership and proper error handling. - Enhanced reward management endpoints to include user validation and ownership checks. - Modified task management endpoints to enforce user authentication and ownership verification. - Updated models to include `user_id` for images, rewards, tasks, and children to track ownership. - Implemented frontend changes to ensure UI reflects the ownership of tasks and rewards. - Added a new feature specification to prevent deletion of system tasks and rewards. --- .github/copilot-instructions.md | 10 +- .../no-delete-system-tasks-and-rewards.md | 26 +++ backend/api/auth_api.py | 16 +- backend/api/child_api.py | 171 +++++++++++++----- backend/api/image_api.py | 31 +++- backend/api/reward_api.py | 70 +++++-- backend/api/task_api.py | 67 +++++-- backend/api/user_api.py | 29 ++- backend/api/utils.py | 14 +- backend/models/child.py | 6 +- backend/models/image.py | 8 +- backend/models/pending_reward.py | 5 +- backend/models/reward.py | 5 +- backend/models/task.py | 7 +- .../src/components/child/ChildView.vue | 1 + .../src/components/profile/UserProfile.vue | 5 +- .../src/components/shared/LoginButton.vue | 9 +- frontend/vue-app/src/stores/auth.ts | 2 + 18 files changed, 361 insertions(+), 121 deletions(-) create mode 100644 .github/specs/active/no-delete-system-tasks-and-rewards.md diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 01514f4..c46898a 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -13,22 +13,16 @@ - **Frontend Styling**: Use only `:root` CSS variables from `global.css` for all colors, spacing, and tokens. Example: `--btn-primary`, `--list-item-bg-good`. - **Scoped Styles**: All `.vue` files must use `