Skip to content
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

Minor improvements to incident edit permissions #2747

Merged
merged 1 commit into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/dispatch/auth/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,9 @@ def has_required_permissions(
if not current_incident:
return False

if current_incident.reporter.individual.email == current_user.email:
return True
if current_incident.reporter:
if current_incident.reporter.individual.email == current_user.email:
return True


class IncidentCommanderPermission(BasePermission):
Expand All @@ -285,7 +286,7 @@ def has_required_permissions(
db_session=request.state.db, incident_id=request.path_params["incident_id"]
)
if not current_incident:
return
return False

if current_incident.commander:
if current_incident.commander.individual.email == current_user.email:
Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/incident/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, Query, status

from sqlalchemy.orm import Session

from dispatch.auth.permissions import (
IncidentEditPermission,
IncidentJoinOrSubscribePermission,
PermissionsDependency,
IncidentViewPermission,
PermissionsDependency,
)

from dispatch.auth.models import DispatchUser
from dispatch.auth.service import get_current_user
from dispatch.common.utils.views import create_pydantic_include
Expand Down