spine-framework 0.3.69 → 0.3.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -248,7 +248,9 @@ async function seedApp(appDir: string, appSlug: string) {
|
|
|
248
248
|
is_active: true,
|
|
249
249
|
route_prefix: manifest.route_prefix ?? ('/' + appSlug),
|
|
250
250
|
renderer: manifest.renderer ?? 'custom',
|
|
251
|
-
//
|
|
251
|
+
// required_roles: full array from manifest (e.g. ["support", "support_admin"])
|
|
252
|
+
required_roles: manifest.required_roles ?? (manifest.min_role ? [manifest.min_role] : []),
|
|
253
|
+
// min_role: kept as legacy fallback — first entry of required_roles
|
|
252
254
|
min_role: manifest.required_roles?.[0] ?? manifest.min_role ?? null,
|
|
253
255
|
},
|
|
254
256
|
{ onConflict: 'slug' }
|
|
@@ -23,9 +23,14 @@ export function AppWrapper({ app, children }: AppWrapperProps) {
|
|
|
23
23
|
return <Navigate to="/login" replace />
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
// Role gate
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
// Role gate — check required_roles array (preferred) or min_role (fallback)
|
|
27
|
+
const requiredRoles: string[] = app.required_roles?.length
|
|
28
|
+
? app.required_roles
|
|
29
|
+
: app.min_role ? [app.min_role] : []
|
|
30
|
+
|
|
31
|
+
if (requiredRoles.length > 0) {
|
|
32
|
+
const hasRole = user.roles?.includes('system_admin') ||
|
|
33
|
+
requiredRoles.some(r => user.roles?.includes(r))
|
|
29
34
|
if (!hasRole) {
|
|
30
35
|
return (
|
|
31
36
|
<div className="min-h-screen flex items-center justify-center bg-slate-50">
|
|
@@ -39,7 +44,7 @@ export function AppWrapper({ app, children }: AppWrapperProps) {
|
|
|
39
44
|
<p className="text-slate-600 mb-6">You don't have permission to access {app.name}.</p>
|
|
40
45
|
<div className="bg-slate-100 rounded-lg p-4 text-left">
|
|
41
46
|
<p className="text-sm text-slate-600 mb-2"><strong>Your roles:</strong> {user.roles?.join(', ') || 'None'}</p>
|
|
42
|
-
<p className="text-sm text-slate-600"><strong>Required:</strong> {
|
|
47
|
+
<p className="text-sm text-slate-600"><strong>Required (any):</strong> {requiredRoles.join(', ')}</p>
|
|
43
48
|
</div>
|
|
44
49
|
</div>
|
|
45
50
|
</div>
|