mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: protect paid courses
This commit is contained in:
parent
b7f09885df
commit
3988ee1d4b
9 changed files with 266 additions and 33 deletions
|
|
@ -19,6 +19,7 @@ from src.services.payments.payments_courses import (
|
|||
)
|
||||
from src.services.payments.payments_webhook import handle_stripe_webhook
|
||||
from src.services.payments.stripe import create_checkout_session
|
||||
from src.services.payments.payments_access import check_course_paid_access
|
||||
|
||||
|
||||
router = APIRouter()
|
||||
|
|
@ -185,3 +186,22 @@ async def api_create_checkout_session(
|
|||
db_session: Session = Depends(get_db_session),
|
||||
):
|
||||
return await create_checkout_session(request, org_id, product_id, redirect_uri, current_user, db_session)
|
||||
|
||||
@router.get("/{org_id}/courses/{course_id}/access")
|
||||
async def api_check_course_paid_access(
|
||||
request: Request,
|
||||
org_id: int,
|
||||
course_id: int,
|
||||
current_user: PublicUser = Depends(get_current_user),
|
||||
db_session: Session = Depends(get_db_session),
|
||||
):
|
||||
"""
|
||||
Check if current user has paid access to a specific course
|
||||
"""
|
||||
return {
|
||||
"has_access": await check_course_paid_access(
|
||||
course_id=course_id,
|
||||
user=current_user,
|
||||
db_session=db_session
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue