-
-
Notifications
You must be signed in to change notification settings - Fork 53
π¨ SECURITY: Fix critical authorization flaw in deleteAppointment #212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
suhas2006-code
wants to merge
8
commits into
AOSSIE-Org:main
Choose a base branch
from
suhas2006-code:fix/patient-delete-appointment-authorization-169
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2de0684
security: fix critical authorization flaw in deleteAppointment
suhas2006-code 01ca604
docs: organize repository structure and move screenshots
suhas2006-code 2495f0c
refactor: replace console print statements with proper logging
suhas2006-code f417b9d
feat: add enhanced database schema and development seeding
suhas2006-code f716695
refactor: remove unused imports to improve code clarity
suhas2006-code e564d18
fix: address CodeRabbit review feedback for database and seeding imprβ¦
suhas2006-code d9f841d
fix: add error validation for count queries in seed script
suhas2006-code f096896
fix: implement CodeRabbit security and pagination recommendations forβ¦
suhas2006-code File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| -- NeuroTrack Database Schema (fixed ordering & syntax) | ||
| -- Run this in Supabase SQL Editor: https://supabase.com/dashboard/project/apqhleefisqnavwxuvqg/sql/new | ||
|
|
||
| -- Create therapist table first (referenced by patient) | ||
| CREATE TABLE IF NOT EXISTS therapist ( | ||
| id UUID PRIMARY KEY REFERENCES auth.users(id) ON DELETE CASCADE, | ||
| created_at TIMESTAMPTZ DEFAULT NOW(), | ||
| name TEXT NOT NULL, | ||
| email TEXT NOT NULL UNIQUE, | ||
| phone TEXT NOT NULL, | ||
| clinic_id UUID, | ||
| license TEXT, | ||
| approved BOOLEAN DEFAULT FALSE, | ||
| specialisation TEXT, | ||
| gender TEXT, | ||
| offered_therapies TEXT[], | ||
| age INT2, | ||
| regulatory_body TEXT, | ||
| start_availability_time TEXT, | ||
| end_availability_time TEXT, | ||
| license_number TEXT | ||
| ); | ||
|
|
||
| -- Create the patient table | ||
| CREATE TABLE IF NOT EXISTS patient ( | ||
| id UUID PRIMARY KEY REFERENCES auth.users(id) ON DELETE CASCADE, | ||
| created_at TIMESTAMPTZ DEFAULT NOW(), | ||
| patient_name TEXT NOT NULL, | ||
| age INT2, | ||
| is_adult BOOLEAN NOT NULL, | ||
| guardian_name TEXT, | ||
| phone TEXT NOT NULL, | ||
| email TEXT NOT NULL UNIQUE, | ||
| guardian_relation TEXT, | ||
| autism_level INT2, | ||
| onboarded_on TIMESTAMPTZ, | ||
| therapist_id UUID REFERENCES therapist(id) ON DELETE SET NULL, | ||
| gender TEXT, | ||
| country TEXT | ||
| ); | ||
|
|
||
| -- Create the package table | ||
| CREATE TABLE IF NOT EXISTS package ( | ||
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | ||
| created_at TIMESTAMPTZ DEFAULT NOW(), | ||
| name TEXT NOT NULL, | ||
| duration INT4 NOT NULL | ||
| ); | ||
|
|
||
| -- Create the session table | ||
| -- TODO: Enable Row-Level Security (RLS) in follow-up PR for defense-in-depth | ||
| -- Will add: ALTER TABLE session ENABLE ROW LEVEL SECURITY; | ||
| -- CREATE POLICY patient_owns_session ON session FOR DELETE USING (patient_id = auth.uid()); | ||
| CREATE TABLE IF NOT EXISTS session ( | ||
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | ||
| created_at TIMESTAMPTZ DEFAULT NOW(), | ||
| timestamp TIMESTAMPTZ NOT NULL, | ||
| therapist_id UUID REFERENCES therapist(id), | ||
| patient_id UUID REFERENCES patient(id), | ||
| is_consultation BOOLEAN DEFAULT FALSE, | ||
| mode INT2, | ||
| duration INT4, | ||
| name TEXT, | ||
| status TEXT NOT NULL CHECK (status IN ('accepted', 'declined', 'pending')) DEFAULT 'pending', | ||
| declined_reason TEXT | ||
| ); | ||
|
|
||
| -- Therapy Table | ||
| CREATE TABLE IF NOT EXISTS therapy ( | ||
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | ||
| created_at TIMESTAMPTZ DEFAULT NOW(), | ||
| name TEXT NOT NULL UNIQUE, | ||
| description TEXT | ||
| ); | ||
|
|
||
| -- Create the therapy_goal table | ||
| CREATE TABLE IF NOT EXISTS therapy_goal ( | ||
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | ||
| created_at TIMESTAMPTZ DEFAULT NOW(), | ||
| performed_on TIMESTAMPTZ, | ||
| therapist_id UUID REFERENCES therapist(id), | ||
| therapy_mode INT2, | ||
| duration INT4, | ||
| therapy_type INT2, | ||
| therapy_type_id UUID REFERENCES therapy(id), | ||
| goals JSONB, | ||
| observations JSONB, | ||
| regressions JSONB, | ||
| activities JSONB, | ||
| patient_id UUID REFERENCES patient(id) | ||
| ); | ||
|
|
||
| -- Create the assessments table | ||
| CREATE TABLE IF NOT EXISTS assessments ( | ||
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | ||
| created_at TIMESTAMPTZ DEFAULT NOW(), | ||
| name TEXT NOT NULL, | ||
| description TEXT, | ||
| category TEXT, | ||
| cutoff_score INT2, | ||
| image_url TEXT, | ||
| questions JSONB NOT NULL | ||
| ); | ||
|
|
||
| -- Create the assessment_results table | ||
| CREATE TABLE IF NOT EXISTS assessment_results ( | ||
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | ||
| created_at TIMESTAMPTZ DEFAULT NOW(), | ||
| assessment_id UUID REFERENCES assessments(id), | ||
| patient_id UUID REFERENCES patient(id), | ||
| submission JSONB, | ||
| result JSONB | ||
| ); | ||
|
|
||
| -- Therapy Goals Master Table | ||
| CREATE TABLE IF NOT EXISTS goal_master ( | ||
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | ||
| created_at TIMESTAMPTZ DEFAULT NOW(), | ||
| goal_text TEXT NOT NULL, | ||
| applicable_therapies UUID[] NOT NULL | ||
| ); | ||
|
|
||
| -- Observations Master Table | ||
| CREATE TABLE IF NOT EXISTS observation_master ( | ||
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | ||
| created_at TIMESTAMPTZ DEFAULT NOW(), | ||
| observation_text TEXT NOT NULL, | ||
| applicable_therapies UUID[] NOT NULL | ||
| ); | ||
|
|
||
| -- Regressions Master Table | ||
| CREATE TABLE IF NOT EXISTS regression_master ( | ||
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | ||
| created_at TIMESTAMPTZ DEFAULT NOW(), | ||
| regression_text TEXT NOT NULL, | ||
| applicable_therapies UUID[] NOT NULL | ||
| ); | ||
|
|
||
| -- Activities Master Table | ||
| CREATE TABLE IF NOT EXISTS activity_master ( | ||
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | ||
| created_at TIMESTAMPTZ DEFAULT NOW(), | ||
| activity_text TEXT NOT NULL, | ||
| applicable_therapies UUID[] NOT NULL | ||
| ); | ||
|
|
||
| -- Daily Activities Table | ||
| CREATE TABLE IF NOT EXISTS daily_activities ( | ||
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | ||
| created_at TIMESTAMPTZ DEFAULT NOW(), | ||
| activity_name TEXT NOT NULL, | ||
| activity_list JSONB, | ||
| is_active BOOLEAN DEFAULT TRUE, | ||
| therapist_id UUID REFERENCES therapist(id) ON DELETE SET NULL, | ||
| patient_id UUID REFERENCES patient(id) ON DELETE CASCADE, | ||
| start_time TIMESTAMPTZ, | ||
| end_time TIMESTAMPTZ, | ||
| days_of_week INT2[] | ||
| ); | ||
|
|
||
| -- Daily Activity Logs Table | ||
| CREATE TABLE IF NOT EXISTS daily_activity_logs ( | ||
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | ||
| activity_id UUID REFERENCES daily_activities(id) ON DELETE CASCADE, | ||
| date TIMESTAMPTZ NOT NULL, | ||
| activity_items JSONB NOT NULL, | ||
| patient_id UUID REFERENCES patient(id) ON DELETE CASCADE | ||
| ); | ||
|
|
||
| -- Indexes on foreign keys for better performance | ||
| CREATE INDEX IF NOT EXISTS idx_patient_therapist_id ON patient(therapist_id); | ||
| CREATE INDEX IF NOT EXISTS idx_session_therapist_id ON session(therapist_id); | ||
| CREATE INDEX IF NOT EXISTS idx_session_patient_id ON session(patient_id); | ||
| CREATE INDEX IF NOT EXISTS idx_therapy_goal_therapist_id ON therapy_goal(therapist_id); | ||
| CREATE INDEX IF NOT EXISTS idx_therapy_goal_patient_id ON therapy_goal(patient_id); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.