Skip to content

Commit

Permalink
refactor: remove role check for DRONE_PILOT from code
Browse files Browse the repository at this point in the history
  • Loading branch information
Pradip-p committed Jul 29, 2024
1 parent df9ceb0 commit 6fb8000
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/backend/app/tasks/task_routes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import uuid
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException
from app.config import settings
from app.models.enums import EventType, State, UserRole
from app.models.enums import EventType, State
from app.tasks import task_schemas, task_crud
from app.users.user_deps import login_required
from app.users.user_schemas import AuthUser
Expand All @@ -27,16 +27,6 @@ async def list_tasks(
"""Get all tasks for a drone user."""

user_id = user_data.id
query = """SELECT role FROM user_profile WHERE user_id = :user_id"""
record = await db.fetch_one(query, {"user_id": user_id})
if not record:
raise HTTPException(status_code=404, detail="User profile not found")

if record.role != UserRole.DRONE_PILOT.name:
raise HTTPException(
status_code=403, detail="Access forbidden for non-DRONE_PILOT users"
)

return await task_crud.get_tasks_by_user(user_id, db)


Expand Down

0 comments on commit 6fb8000

Please sign in to comment.