Skip to content
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
8 changes: 4 additions & 4 deletions backend/api/issues/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from backend.models.dtos.mapping_issues_dto import MappingIssueCategoryDTO
from backend.models.dtos.user_dto import AuthUserDTO
from backend.services.mapping_issues_service import MappingIssueCategoryService
from backend.services.users.authentication_service import pm_only
from backend.services.users.authentication_service import admin_only

router = APIRouter(
prefix="/tasks",
Expand Down Expand Up @@ -52,7 +52,7 @@ async def get_issue(category_id: int, db: Database = Depends(get_db)):
async def patch_issue(
request: Request,
category_id: int,
user: AuthUserDTO = Depends(pm_only),
user: AuthUserDTO = Depends(admin_only),
db: Database = Depends(get_db),
data: MappingIssueCategoryDTO = Body(...),
):
Expand Down Expand Up @@ -121,7 +121,7 @@ async def patch_issue(
async def delete_issue(
request: Request,
category_id: int,
user: AuthUserDTO = Depends(pm_only),
user: AuthUserDTO = Depends(admin_only),
db: Database = Depends(get_db),
):
"""
Expand Down Expand Up @@ -200,7 +200,7 @@ async def get_issues_categories(
@router.post("/issues/categories/", response_model=MappingIssueCategoryDTO)
async def post_issues_categories(
request: Request,
user: AuthUserDTO = Depends(pm_only),
user: AuthUserDTO = Depends(admin_only),
db: Database = Depends(get_db),
data: dict = Body(...),
):
Expand Down
8 changes: 4 additions & 4 deletions backend/api/licenses/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from backend.models.dtos.licenses_dto import LicenseDTO
from backend.models.dtos.user_dto import AuthUserDTO
from backend.services.license_service import LicenseService
from backend.services.users.authentication_service import pm_only
from backend.services.users.authentication_service import admin_only

router = APIRouter(
prefix="/licenses",
Expand All @@ -19,7 +19,7 @@
async def post_license(
license_dto: LicenseDTO,
db: Database = Depends(get_db),
user: AuthUserDTO = Depends(pm_only),
user: AuthUserDTO = Depends(admin_only),
):
"""
Creates a new mapping license
Expand Down Expand Up @@ -100,7 +100,7 @@ async def patch_license(
license_dto: LicenseDTO,
license_id: int,
db: Database = Depends(get_db),
user: AuthUserDTO = Depends(pm_only),
user: AuthUserDTO = Depends(admin_only),
):
"""
Update a specified mapping license
Expand Down Expand Up @@ -155,7 +155,7 @@ async def patch_license(
async def delete_license(
license_id: int,
db: Database = Depends(get_db),
user: AuthUserDTO = Depends(pm_only),
user: AuthUserDTO = Depends(admin_only),
):
"""
Delete a specified mapping license
Expand Down
8 changes: 4 additions & 4 deletions backend/api/mapping_badges/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)
from backend.models.dtos.user_dto import AuthUserDTO
from backend.services.mapping_badges import MappingBadgeService
from backend.services.users.authentication_service import pm_only
from backend.services.users.authentication_service import admin_only

router = APIRouter(
prefix="/badges",
Expand Down Expand Up @@ -39,7 +39,7 @@ async def get_mapping_badges(
async def create_mapping_badge(
data: MappingBadgeCreateDTO,
db: Database = Depends(get_db),
user: AuthUserDTO = Depends(pm_only),
user: AuthUserDTO = Depends(admin_only),
) -> MappingBadgeDTO:
"""
Creates a new MappingBadge
Expand Down Expand Up @@ -73,7 +73,7 @@ async def update_mapping_badge(
data: MappingBadgeUpdateDTO,
badge_id: int,
db: Database = Depends(get_db),
user: AuthUserDTO = Depends(pm_only),
user: AuthUserDTO = Depends(admin_only),
) -> MappingBadgeDTO:
"""
Updates a mapping badge
Expand All @@ -92,7 +92,7 @@ async def update_mapping_badge(
async def delete_mapping_badge(
badge_id: int,
db: Database = Depends(get_db),
user: AuthUserDTO = Depends(pm_only),
user: AuthUserDTO = Depends(admin_only),
):
"""
Deletes a mapping badge
Expand Down
8 changes: 4 additions & 4 deletions backend/api/mapping_levels/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
from backend.models.dtos.user_dto import AuthUserDTO
from backend.services.mapping_levels import MappingLevelService
from backend.services.users.authentication_service import pm_only
from backend.services.users.authentication_service import admin_only

router = APIRouter(
prefix="/levels",
Expand Down Expand Up @@ -36,7 +36,7 @@ async def get_mapping_levels(
async def create_mapping_level(
data: MappingLevelCreateDTO,
db: Database = Depends(get_db),
user: AuthUserDTO = Depends(pm_only),
user: AuthUserDTO = Depends(admin_only),
):
"""
Create a new mapping level
Expand Down Expand Up @@ -70,7 +70,7 @@ async def update_mapping_level(
data: MappingLevelUpdateDTO,
level_id: int,
db: Database = Depends(get_db),
user: AuthUserDTO = Depends(pm_only),
user: AuthUserDTO = Depends(admin_only),
):
"""
Update a given mapping level
Expand All @@ -89,7 +89,7 @@ async def update_mapping_level(
async def delete_mapping_level(
level_id: int,
db: Database = Depends(get_db),
user: AuthUserDTO = Depends(pm_only),
user: AuthUserDTO = Depends(admin_only),
):
"""
Delete the specified mapping level
Expand Down
12 changes: 6 additions & 6 deletions backend/api/users/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from backend.models.dtos.user_dto import AuthUserDTO, UserDTO, UserRegisterEmailDTO
from backend.services.interests_service import InterestService
from backend.services.messaging.message_service import MessageService
from backend.services.users.authentication_service import login_required, pm_only
from backend.services.users.authentication_service import login_required, admin_only
from backend.services.users.user_service import UserService, UserServiceError

router = APIRouter(
Expand Down Expand Up @@ -117,7 +117,7 @@ async def set_mapping_level(
request: Request,
username,
level,
user: AuthUserDTO = Depends(pm_only),
user: AuthUserDTO = Depends(admin_only),
db: Database = Depends(get_db),
):
"""
Expand Down Expand Up @@ -173,7 +173,7 @@ async def set_user_role(
request: Request,
username: str,
role: str,
user: AuthUserDTO = Depends(pm_only),
user: AuthUserDTO = Depends(admin_only),
db: Database = Depends(get_db),
):
"""
Expand Down Expand Up @@ -228,7 +228,7 @@ async def set_user_role(
async def update_stats(
request: Request,
username: str,
_: AuthUserDTO = Depends(pm_only),
_: AuthUserDTO = Depends(admin_only),
db: Database = Depends(get_db),
):
"""
Expand All @@ -255,7 +255,7 @@ async def update_stats(
async def approve_level(
request: Request,
username: str,
voter: AuthUserDTO = Depends(pm_only),
voter: AuthUserDTO = Depends(admin_only),
db: Database = Depends(get_db),
):
"""
Expand All @@ -282,7 +282,7 @@ async def set_user_is_expert(
request: Request,
user_name,
is_expert,
user: AuthUserDTO = Depends(pm_only),
user: AuthUserDTO = Depends(admin_only),
db: Database = Depends(get_db),
):
"""
Expand Down
2 changes: 1 addition & 1 deletion backend/services/users/authentication_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ async def login_required_optional(
return AuthUserDTO(id=user_id)


async def pm_only(
async def admin_only(
Authorization: str = Security(APIKeyHeader(name="Authorization")),
db: Database = Depends(get_db),
):
Expand Down