mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
refactor: update RBAC check logic and improve comments in get_certificate_by_user_certification_uuid function
This commit is contained in:
parent
f84529e467
commit
0138174f6a
1 changed files with 2 additions and 5 deletions
|
|
@ -425,7 +425,7 @@ async def get_certificate_by_user_certification_uuid(
|
||||||
detail="Certification not found",
|
detail="Certification not found",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Get course for RBAC check
|
# Get course information
|
||||||
statement = select(Course).where(Course.id == certification.course_id)
|
statement = select(Course).where(Course.id == certification.course_id)
|
||||||
course = db_session.exec(statement).first()
|
course = db_session.exec(statement).first()
|
||||||
|
|
||||||
|
|
@ -435,10 +435,7 @@ async def get_certificate_by_user_certification_uuid(
|
||||||
detail="Course not found",
|
detail="Course not found",
|
||||||
)
|
)
|
||||||
|
|
||||||
# RBAC check - allow read access to the certificate owner or course owners/admins
|
# No RBAC check - allow anyone to access certificates by UUID
|
||||||
if current_user.id != certificate_user.user_id:
|
|
||||||
# If not the certificate owner, check course access
|
|
||||||
await rbac_check(request, course.course_uuid, current_user, "read", db_session)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"certificate_user": CertificateUserRead(**certificate_user.model_dump()),
|
"certificate_user": CertificateUserRead(**certificate_user.model_dump()),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue