Skip to content

Commit

Permalink
Allow external users from online endpoints (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
armanddidierjean authored Aug 23, 2024
1 parent f11a3f3 commit 82167fb
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions app/modules/cdr/endpoints_cdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
get_payment_tool,
get_settings,
get_websocket_connection_manager,
is_user,
is_user_a_member,
is_user_a_member_of,
)
Expand Down Expand Up @@ -342,7 +343,7 @@ async def get_sellers_by_user_id(
)
async def get_online_sellers(
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
"""
Get all sellers that has online available products.
Expand All @@ -359,7 +360,7 @@ async def get_online_sellers(
)
async def get_all_available_online_products(
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
"""
Get a seller's online available products.
Expand Down Expand Up @@ -527,7 +528,7 @@ async def get_products_by_seller_id(
async def get_available_online_products(
seller_id: UUID,
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
"""
Get a seller's online available products.
Expand Down Expand Up @@ -1067,7 +1068,7 @@ async def delete_document(
async def get_purchases_by_user_id(
user_id: str,
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
"""
Get a user's purchases.
Expand Down Expand Up @@ -1118,7 +1119,7 @@ async def get_purchases_by_user_id(
)
async def get_my_purchases(
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
return await get_purchases_by_user_id(user.id, db, user)

Expand All @@ -1132,7 +1133,7 @@ async def get_purchases_by_user_id_by_seller_id(
seller_id: UUID,
user_id: str,
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
"""
Get a user's purchases.
Expand Down Expand Up @@ -1185,7 +1186,7 @@ async def create_purchase(
product_variant_id: UUID,
purchase: schemas_cdr.PurchaseBase,
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
"""
Create a purchase.
Expand Down Expand Up @@ -1521,7 +1522,7 @@ async def delete_purchase(
user_id: str,
product_variant_id: UUID,
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
"""
Delete a purchase.
Expand Down Expand Up @@ -1631,7 +1632,7 @@ async def delete_purchase(
async def get_signatures_by_user_id(
user_id: str,
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
"""
Get a user's signatures.
Expand All @@ -1658,7 +1659,7 @@ async def get_signatures_by_user_id_by_seller_id(
seller_id: UUID,
user_id: str,
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
"""
Get a user's signatures for a single seller.
Expand All @@ -1685,7 +1686,7 @@ async def create_signature(
document_id: UUID,
signature: schemas_cdr.SignatureBase,
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
"""
Create a signature.
Expand Down Expand Up @@ -1789,7 +1790,7 @@ async def delete_signature(
)
async def get_curriculums(
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
"""
Get all curriculums.
Expand Down Expand Up @@ -1876,7 +1877,7 @@ async def create_curriculum_membership(
user_id: str,
curriculum_id: UUID,
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
ws_manager: WebsocketConnectionManager = Depends(get_websocket_connection_manager),
):
"""
Expand Down Expand Up @@ -1961,7 +1962,7 @@ async def update_curriculum_membership(
user_id: str,
curriculum_id: UUID,
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
ws_manager: WebsocketConnectionManager = Depends(get_websocket_connection_manager),
):
"""
Expand Down Expand Up @@ -2034,7 +2035,7 @@ async def delete_curriculum_membership(
user_id: str,
curriculum_id: UUID,
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
ws_manager: WebsocketConnectionManager = Depends(get_websocket_connection_manager),
):
"""
Expand Down Expand Up @@ -2105,7 +2106,7 @@ async def delete_curriculum_membership(
async def get_payments_by_user_id(
user_id: str,
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
"""
Get a user's payments.
Expand Down Expand Up @@ -2225,7 +2226,7 @@ async def delete_payment(
)
async def get_payment_url(
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
settings: Settings = Depends(get_settings),
payment_tool: PaymentTool = Depends(get_payment_tool),
):
Expand Down Expand Up @@ -2284,7 +2285,7 @@ async def get_payment_url(
async def get_memberships_by_user_id(
user_id: str,
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
if not (
user_id == user.id
Expand Down Expand Up @@ -2360,7 +2361,7 @@ async def delete_membership(
)
async def get_status(
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
return await get_core_data(schemas_cdr.Status, db)

Expand Down Expand Up @@ -2411,7 +2412,7 @@ async def update_status(
async def get_tickets_of_user(
user_id: str,
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
if not (
is_user_member_of_an_allowed_group(user, [GroupType.admin_cdr])
Expand All @@ -2432,7 +2433,7 @@ async def get_tickets_of_user(
async def get_ticket_secret(
ticket_id: UUID,
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
user: models_core.CoreUser = Depends(is_user),
):
ticket = await cruds_cdr.get_ticket(db=db, ticket_id=ticket_id)
if not ticket:
Expand Down

0 comments on commit 82167fb

Please sign in to comment.