Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update backend_structured/routes.py
Browse files
backend_structured/routes.py
CHANGED
|
@@ -1820,12 +1820,10 @@ def get_scans_history(current_user):
|
|
| 1820 |
|
| 1821 |
if org_id_param and current_user.role in ['super_admin', 'admin', 'support_engineer']:
|
| 1822 |
scans_query = Scan.query.filter_by(org_id=org_id_param)
|
| 1823 |
-
elif
|
| 1824 |
scans_query = Scan.query
|
| 1825 |
-
elif current_user.org_id
|
| 1826 |
scans_query = Scan.query.filter_by(org_id=current_user.org_id)
|
| 1827 |
-
elif current_user.role in ['super_admin', 'support_engineer']:
|
| 1828 |
-
scans_query = Scan.query
|
| 1829 |
else:
|
| 1830 |
scans_query = Scan.query.filter_by(user_id=current_user.id)
|
| 1831 |
|
|
@@ -2290,14 +2288,14 @@ def manage_alert_settings(current_user):
|
|
| 2290 |
def get_scan_for_user(scan_id, current_user):
|
| 2291 |
"""
|
| 2292 |
Retrieve scan object with role-based access permissions:
|
| 2293 |
-
- Super Admins & Support Engineers: full system-wide access to all scans.
|
| 2294 |
-
- Org
|
| 2295 |
- Standard Users: access to scans they created.
|
| 2296 |
"""
|
| 2297 |
scan = db.session.get(Scan, scan_id)
|
| 2298 |
if not scan:
|
| 2299 |
return None
|
| 2300 |
-
if current_user.role in ('super_admin', 'support_engineer'):
|
| 2301 |
return scan
|
| 2302 |
if current_user.org_id and scan.org_id == current_user.org_id:
|
| 2303 |
return scan
|
|
|
|
| 1820 |
|
| 1821 |
if org_id_param and current_user.role in ['super_admin', 'admin', 'support_engineer']:
|
| 1822 |
scans_query = Scan.query.filter_by(org_id=org_id_param)
|
| 1823 |
+
elif current_user.role in ['super_admin', 'admin', 'support_engineer']:
|
| 1824 |
scans_query = Scan.query
|
| 1825 |
+
elif current_user.org_id:
|
| 1826 |
scans_query = Scan.query.filter_by(org_id=current_user.org_id)
|
|
|
|
|
|
|
| 1827 |
else:
|
| 1828 |
scans_query = Scan.query.filter_by(user_id=current_user.id)
|
| 1829 |
|
|
|
|
| 2288 |
def get_scan_for_user(scan_id, current_user):
|
| 2289 |
"""
|
| 2290 |
Retrieve scan object with role-based access permissions:
|
| 2291 |
+
- Super Admins, Admins & Support Engineers: full system-wide access to all scans.
|
| 2292 |
+
- Org Members: access to all scans created in their organization.
|
| 2293 |
- Standard Users: access to scans they created.
|
| 2294 |
"""
|
| 2295 |
scan = db.session.get(Scan, scan_id)
|
| 2296 |
if not scan:
|
| 2297 |
return None
|
| 2298 |
+
if current_user.role in ('super_admin', 'admin', 'support_engineer'):
|
| 2299 |
return scan
|
| 2300 |
if current_user.org_id and scan.org_id == current_user.org_id:
|
| 2301 |
return scan
|