Implement RBAC for library content management in club tenancy
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 41s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 11s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Has been cancelled
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 41s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 11s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Has been cancelled
- Introduced new functions for managing edit, delete, and governance transition permissions for library content, aligning with role-based access control (RBAC) principles. - Updated existing routers to utilize these new functions, ensuring consistent permission checks across training frameworks, modules, and progression graphs. - Enhanced visibility and governance handling for training plan templates and library content, improving overall content management and user experience. - Incremented app version to 0.8.142 and updated changelog to reflect these changes.
This commit is contained in:
1 parent
bc1790bd82
commit
0275f76432
9 files changed
+368
-64
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { activeClubMemberships } from './activeClub'
|
||||
|
||||
export function clubAdminInClub(user, clubId) {
|
||||
const cid = Number(clubId)
|
||||
if (!Number.isFinite(cid)) return false
|
||||
const row = activeClubMemberships(user?.clubs).find((c) => Number(c.id) === cid)
|
||||
return Boolean(row?.roles?.includes('club_admin'))
|
||||
}
|
||||
|
||||
/**
|
||||
* Löschen von Bibliotheks-/Planungsinhalten (Vorlage, Modul, Rahmen, Graph) — grob wie Backend club_tenancy.
|
||||
* Vereins-Admins können fremde private Einträge im API löschen (gemeinsamer Verein); das blenden wir hier nicht ein.
|
||||
*/
|
||||
export function canDeleteLibraryContent(user, row) {
|
||||
const grole = String(user?.role || '').toLowerCase()
|
||||
if (grole === 'admin' || grole === 'superadmin') return true
|
||||
const uid = Number(user?.id)
|
||||
if (!Number.isFinite(uid)) return false
|
||||
|
||||
const vis = String(row?.visibility ?? 'club').toLowerCase()
|
||||
const createdBy = row?.created_by != null ? Number(row.created_by) : null
|
||||
const clubId = row?.club_id != null ? Number(row.club_id) : null
|
||||
|
||||
if (vis === 'official') return false
|
||||
if (vis === 'club') return clubAdminInClub(user, clubId)
|
||||
if (vis === 'private') return Number.isFinite(createdBy) && createdBy === uid
|
||||
return false
|
||||
}
|
||||
Reference in new issue
Block a user