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

Develop #58

Merged
merged 2 commits into from
Nov 25, 2024
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
4 changes: 3 additions & 1 deletion src/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from fastapi_cache.decorator import cache
from slugify import slugify

from src.common.helpers.caching import custom_key_builder, delete_custom_key
from src.config import enable_endpoint, settings
from src.common.helpers.caching import custom_key_builder
from src.middleware import AuthorizedHTTPBearer
from src.models import User
from src.schemas import (
Expand Down Expand Up @@ -76,6 +76,8 @@ async def resend_otp_code(bg: BackgroundTasks, payload: PhonenumberModel = Body(
"/logout", dependencies=[Depends(AuthorizedHTTPBearer)], summary="Logout User", status_code=status.HTTP_200_OK
)
async def logout(request: Request):
await delete_custom_key(service_appname_slug + "access")
await delete_custom_key(service_appname_slug + "validate")
return await auth.logout(request)


Expand Down
6 changes: 6 additions & 0 deletions src/routers/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
from fastapi import APIRouter, Body, Depends, Query, status
from fastapi_pagination.ext.beanie import paginate
from pymongo import ASCENDING, DESCENDING
from slugify import slugify

from src.common.helpers.caching import delete_custom_key
from src.config import enable_endpoint, settings
from src.middleware import AuthorizedHTTPBearer, CheckPermissionsHandler
from src.models import Role
from src.schemas import RoleModel
from src.services import roles
from src.shared.utils import customize_page, SortEnum

service_appname_slug = slugify(settings.APP_NAME)

role_router = APIRouter(prefix="/roles", tags=["ROLES"], redirect_slashes=False)


Expand Down Expand Up @@ -141,4 +145,6 @@ async def get_role_members(
status_code=status.HTTP_200_OK,
)
async def manage_permission_to_role(id: PydanticObjectId, payload: Set[str] = Body(...)):
await delete_custom_key(service_appname_slug + "access")
await delete_custom_key(service_appname_slug + "validate")
return await roles.assign_permissions_to_role(role_id=PydanticObjectId(id), permission_codes=payload)
Loading